Version
Wwise Unity Integration Documentation
|
The Unity Addressables system uses AssetBundles to package assets separately from the player. This is particularily useful in the context of DLC, where the extra assets can be stored on an external server.
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:
Be aware of the following characteristics of the Addressables system:
The Wwise Addressable Samples page provides additional information about code samples designed to help manage Wwise addressable assets.
The WwiseBankImporter classes process .bnk
and .wem
files. This script creates assets containing the binary data of the files. Our custom asset postprocessor WwiseBankPostProcess then adds the new assets to the Addressables group of their respective platform. The Init SoundBank for each platform is added to its own Addressables group. The reason the Init Bank is kept separate is because it must be updated when modifications to the project (such as adding new audio busses) are made post-release. By packaging the Init SoundBank in its own addressable AssetBundle, we minimize the time it will take to fetch the new version of this asset from the hosting service. If you wish to customize what addressable group the assets are added to, and which labels are applied to the assets, please consult the Wwise Addressable Samples page.
The asset postprocessor also creates a WwiseAddressableSoundBank for each SoundBank in the project. This asset contains a dictionary that maps platform names to their respective SoundBank and streaming media assets.
Caution:
|
When the WwiseAddressableSoundBank for the Init SoundBank is created, an InitBankHolder component will be added to the WwiseGlobal gameobject in the scene. This component simply stores the WwiseAddressableSoundBank so that the AddressableBankManager can find it easily.
When using Wwise Addressables, the AkAddressableBankManager handles loading and unloading of SoundBanks into memory. This class stores references to loading and loaded AddressableSoundBanks and ensures that the Init SoundBank is always loaded first. 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. Asynchronous loading can only be tested in the built game.
Note: | Ensure that you use AkBank to load your SoundBanks instead of manually calling the API. |
The WwiseBankReference class is used in our custom inspector for the Ak.Wwise.Bank component. The WwiseBankReference contains a hard reference to a WwiseAddressableSoundBank. This reference is updated when a WwiseAddressableSoundBank Asset is created via the AkAssetUtilities.AddressableBankUpdated delegate. If the WwiseBankReference is created after the WwiseAddressableSoundBank, it will search in the SoundBanks folder for a WwiseAddressableSoundBank asset matching its bank name. Serialized WwiseBankReferences are stored in Assets\Wwise\ScriptableObjects\SoundBank
.
Note: | Any assets that are referenced directly by a game object will be packaged with the game object. AkBank Components contain a hard reference to a WwiseBankReference, and the WwiseBankReference contains a hard reference to its corresponding WwiseAddressableSoundBank. If you put a GameObject with an AkBank component in an Addressables group, the WwiseBankReference and WwiseAddressableSoundBank will be packaged with it (without having to explicitly add them to the group). |
Streaming media (.wem files) are also handled by the WwiseBankImporter script. The WwiseAddressableSoundBank contains a list of references to the platform specific streaming media assets associated with the bank. When a bank is loaded, the media assets are loaded via Addressables and copied to the Application.persistentDataPath folder. If a file with the same name already exists in the folder, their hashes are compared. If the files differ, the file is overwritten by the one from the AssetBundle.
Questions? Problems? Need more info? Contact us, and we can help!
Visit our Support pageRegister your project and we'll help you get started with no strings attached!
Get started with Wwise