版本

menu_open
Wwise Unity Integration Documentation
在 Unity 中使用 Wwise Addressables Package

关于 Unity Addressables

The Unity Addressables system uses AssetBundles to package assets separately from the player. 该系统在 DLC 开发当中特别有用,方便将额外的素材存储到外部服务器上。

If you are new to Addressables, see
Addressables package and Get started with Addressables for essential background information.

The following topics explain how to set up the Wwise Unity Addressables package:

The following sections describe how the Wwise Addressables package works:

Characteristics of the Addressables System

Be aware of the following characteristics of the Addressables system:

  • “使用 Addressables 加载素材”本身属于异步操作:倘若加载的 SoundBank 和发送的 Event 被关联到了同一 Trigger,有可能会出现问题。在需要精确设定 Event 时机的情况下,建议先加载 SoundBank,再触发关联 Event。Init Soundbank 是个特例,其必须在场景中的所有其他 SoundBank 之前加载。若以远程方式更新 Init Soundbank 素材,则在场景启动并加载 SoundBank 时会稍有延迟,因为要先使用 Addressables 从 Web 服务器获取新的 Init Soundbank。
  • 不可在场景中直接引用 Addressables 素材:Addressables 素材必须使用 Addressables 系统在场景中动态加载。场景中直接引用的素材会构建到场景的 AssetBundle 中,而不会通过 Addressables 加载。若将素材直接放在场景中,同时使用 Addressables 打包该素材,则游戏数据中将会有两份不同的素材:场景的 AssetBundle 中一份,Addressables 分组的 AssetBundle 中一份。

已知问题和限制

  • 工程中的所有平台必须共用同一 Generated SoundBanks Path 根目录。
  • 在 Unity 工程中设置 Generated SoundBank Path 不会自动更改 External Source 的输出路径。
  • 暂不支持保存和加载 Decoded SoundBank。
  • 暂不支持 Prepared Event。
  • 暂不支持 External Source。

Wwise Addressable 示例

Wwise Addressables 示例 页面提供有关如何参照代码示例管理 Wwise Addressables 素材的附加信息。

Understanding Wwise Addressable Assets

Wwise 素材导入程序

The WwiseBankImporter classes process .bnk and .wem files. 此脚本会创建包含所述文件二进制数据的素材。随后,我们的自定义素材后处理程序 WwiseBankPostProcess 会将新素材添加到相应平台的 Addressables 分组。 接着,针对每个平台将 Init SoundBank 添加到其各自的 Addressables 分组。之所以分开添加 Init SoundBank,是因为在发布后对工程实施更改(比如添加新的音频总线)时必须予以更新。 通过将 Init SoundBank 打包到各自的 Addressables 素材包,我们可以最大限度地缩短使用托管服务获取新版素材所需的时间。 若想自定义要将素材添加到哪个 Addressables 分组以及将哪些标签应用于素材,请参阅 Wwise Addressables 示例 页面。

SoundBank 和 AddressableSoundBank

素材后处理程序还会为工程中的每个 SoundBank 创建一个 WwiseAddressableSoundBank。 此素材包含用来将平台名称映射到相应 SoundBank 和流播放媒体素材的词典。

  • WwiseAddressableSoundBank 存放在 Generated SoundBanks 文件夹的根目录下。
  • WwiseAddressableSoundBank 类使用 AssetReferenceT 指向 SoundBank 和媒体文件。
  • 在构建工程时,将把 WwiseAddressableSoundBank 的 Current Platfrom Assets 字段设为目标构建平台。
注意:
  • WwiseAddressableSoundBank 中 SoundBank 和流播放媒体的引用为软引用。这些文件将使用 Addressables 加载且必须打包到 Addressables 分组中。
  • 若意外删除 WwiseAddressableSoundBank,则须删除并重新生成与之关联的 SoundBank,以便另行新建并正确设置引用。

Init Bank Holder

在针对 Init SoundBank 创建 WwiseAddressableSoundBank 时,将向场景中的 “WwiseGlobal” GameObject 添加 InitBankHolder 组件。 此组件只是简单地存储 WwiseAddressableSoundBank 以便 AddressableBankManager 轻松找到它。

Addressable Bank Manager

When using Wwise Addressables, the AkAddressableBankManager handles loading and unloading of SoundBanks into memory. 此类会存储对正在和已经加载的 AddressableSoundBank 的引用,并确保始终最先加载 Init SoundBank。 If an AkEvent is triggered before its SoundBank has finished loading, this class stores the triggered call's parameters and retriggers the event after the SoundBank is loaded.

When a SoundBank is loaded, the SoundBank asset that corresponds to the current platform is loaded using Addressables. After it is loaded, the SoundBank data is pinned and a copy of the memory is loaded into the sound engine with AkUnitySoundEngine.LoadBankMemoryCopy().

When in Play Mode in the Unity editor, the AssetDatabase is used instead of Addressables to load SoundBanks synchronously. 也就是说,只能在构建好的游戏中测试异步加载。

备注:Ensure that you use AkBank to load your SoundBanks instead of manually calling the API.

WwiseBankReference

WwiseBankReference 类用在 Ak.Wwise.Bank 组件的自定义检视器中。 WwiseBankReference 包含对 WwiseAddressableSoundBank 的硬引用。 在通过 AkAssetUtilities.AddressableBankUpdated 委托创建 WwiseAddressableSoundBank Asset 时,会更新此引用。 若在 WwiseAddressableSoundBank 之后创建 WwiseBankReference ,则将在 SoundBanks 文件夹中搜索与 SoundBank 名称匹配的 WwiseAddressableSoundBank 素材。 序列化的 WwiseBankReference 存储在 Assets\Wwise\ScriptableObjects\SoundBank 下。

备注:游戏对象直接引用的素材会随该游戏对象一并打包。 AkBank 组件包含对 WwiseBankReference 的硬引用,WwiseBankReference 则包含对对应 WwiseAddressableSoundBank 的硬引用。 若将带有 AkBank 组件的游戏对象放在 Addressables 分组中,则将随之一并打包 WwiseBankReference 和 WwiseAddressableSoundBank(无须显式添加到分组中)。

Media

Media files (.wem) are also handled by the WwiseBankImporter script. WwiseAddressableSoundBank 包含一系列对 SoundBank 关联平台专用流播放媒体素材的引用。 在加载 SoundBank 时会通过 Addressables 加载媒体素材,并将其复制到 the Application.persistentDataPath 文件夹中。 若文件夹中已存在同名文件,则对两者的哈希值进行比对。若两个文件不同,则使用 AssetBundle 中的文件加以覆盖。

\akcautionWhen working with Microsoft consoles, it is important to add the PersistentLocalStorage field to the MicrosoftGame.Config. We recommend at least 1024mb.


此页面对您是否有帮助?

需要技术支持?

仍有疑问?或者问题?需要更多信息?欢迎联系我们,我们可以提供帮助!

查看我们的“技术支持”页面

介绍一下自己的项目。我们会竭力为您提供帮助。

来注册自己的项目,我们帮您快速入门,不带任何附加条件!

开始 Wwise 之旅