You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity中Wwise外部音源播放报错:无法找到Gong_2.wem文件求助

Unity播放Wwise外部音源报错:"Wwise: Cannot open file: Gong_2.wem" 排查方案

问题背景

在Unity中播放Wwise外部音源时触发报错,SoundBank已加载、Play_Voice事件可触发,但始终提示找不到Gong_2.wem文件。相关配置与代码如下:

外部音源配置文件(ExternalSources.wsources)

<?xml version="1.0" encoding="UTF-8"?>
<ExternalSourcesList SchemaVersion="1" Root="..\Assets\WwiseExternalSources">
    <Source Path="SeedDrop.wav" Conversion="Default Conversion Settings" />
    <Source Path="Gong_2.wav" Conversion="Default Conversion Settings" />
    <Source Path="shyApplauseTemp.wav" Conversion="Default Conversion Settings" />
</ExternalSourcesList>

Wwise输出路径

D:\game\WwiseProject\GeneratedSoundBanks\Windows(生成SoundBank后该目录下存在所有.wem文件)

播放代码

AkExternalSourceInfo source = new AkExternalSourceInfo();
source.iExternalSrcCookie = AkSoundEngine.GetIDFromString("External_Source");
source.szFile = "Gong_2.wem";
source.idCodec = AkSoundEngine.AKCODECID_PCM;
AkSoundEngine.PostEvent("Play_Voice", gameObject, 0, null, null, 1, source);

排查与解决方法

1. 确认Wwise文件查找路径

Wwise默认在SoundBank加载目录或AkSoundEngine.SetBasePath指定的根目录下查找外部音源:

  • 检查SoundBank的加载路径是否与.wem文件所在的D:\game\WwiseProject\GeneratedSoundBanks\Windows一致
  • 若路径不一致,要么调用AkSoundEngine.SetBasePath将根路径指向.wem所在目录,要么将.wem文件复制到SoundBank加载目录

2. 校验外部音源Cookie匹配

source.iExternalSrcCookie必须与Wwise工程中对应外部音源的External Source Name完全一致:

  • 打开Wwise工程,找到Play_Voice事件关联的Sound对象,查看其外部音源的名称是否为External_Source,名称不匹配会导致Wwise无法定位对应配置

3. 修正编解码器ID设置

代码中设置AKCODECID_PCM不符合实际情况:

  • .wem文件是Wwise转换后的格式,默认用Vorbis等编解码器而非PCM,需匹配Wwise转换设置中的编解码器(例如Vorbis对应AkSoundEngine.AKCODECID_VORBIS)
  • 也可直接移除source.idCodec赋值,让Wwise自动识别文件编码

4. 测试绝对路径有效性

暂时将代码中的文件名替换为绝对路径验证:

source.szFile = @"D:\game\WwiseProject\GeneratedSoundBanks\Windows\Gong_2.wem";

若能正常播放,说明是路径查找逻辑问题,再调整相对路径或BasePath

5. 验证ExternalSources.wsources的Root路径

确认Root="..\Assets\WwiseExternalSources"相对于Wwise工程文件的位置是否正确,若路径错误会导致生成SoundBank时无法正确关联外部音源信息,需在Wwise工程中重新配置外部音源路径

6. 重新生成SoundBank

打开Wwise的SoundBank生成窗口,确认已勾选包含外部音源的选项,重新生成SoundBank确保外部音源信息被正确打包

内容的提问来源于stack exchange,提问作者Arcueid D'athemon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 21:45:32