Addressables
Last updated
Last updated
Addressables is a dynamic asset management solution provided by Unity. It helps determine which audio clips should be loaded, when thet are needed, and how they are loaded.
This documentation covers use Addessables in BroAudio. For further details and the official Addressables manual, please refer to the Unity Manual.
To install Addressables package, please follow the instructions in Unity's manual. Once the package is installed, BroAudio will automatically unlock all addressables related options. No futher configurations needed!
Addressables requires two things to work:
An asset marked as Addressables.
An AssetReference for addressing the asset.
The first step is pretty straightforward. Just find all the audio clips you plan to use with Addressables and mark them as Addressable in the inspector.
The second step is also simple. Open the LibraryManager, select an entity, and you will see an Addressables checkbox in the upper-right area of the Clips tab. Just check it!
These two steps can actually be done at the same time. You can first add audio clips to an entity and then mark the entity as Addressable. If the entity already contains clips, a Reference Conversion Confirmation window will appear, asking how you want to handle them.
One major benefit of using Addressables is that it utilizes indirect references (usually with AssetReference
). This means the asset is not loaded immediately when referenced, unlike direct references, helping reduce memory usage at runtime.
The confirmation window provides three options:
[Yes]
Converts the current clip list to AssetReference
and automatically marks the corresponding audio clip assets as Addressable, so you don't have to mark them manually.
[Yes, don't ask again] Same as [Yes], but remembers your choice so the window won’t appear again..
[No] or close the window No changes are made, and the Addressables checkbox remains as is.
The same confirmation window will also popup when the list is already using AssetReference
, but in the opposite way. Clicking [Yes] will convert the clip list to direct references and unmark all corresponding audio clip assets as Addressable.
You can configure additional options for reference conversion under Tools/BroAudio/Preferences - Miscellaneous.
Always Ask Always show the confirmation window.
Only Convert Convert the list to the target reference type without changing the Addressables state of the clip assets.
Convert And Set Addressables Convert the list and mark/unmark Addressables on the clip assets. This is the default behavior for [Yes] and [Yes, don't ask again]. Plus, [don't ask again] will change the setting to this option while [Yes] remains on Always Ask.
Convert And Clear All References Convert the list and remove all references from it.
Now that the audio clips are set as Addressables, managing their loading process is up to us.
The API functions similarly to Unity’s standard Addressables APIs. You call the loading method, get an AsyncOperationHandle, wait for it to complete before using the asset, and release it when it's no longer needed.
LoadAllAssetsAsync
Loads all the audio clips in the entity
LoadAssetAsync
Loads the first audio clips in the entity
Loads the audio clip in the entity's clip list by index
ReleaseAllAssets
void
Releases all the audio clips in the entity
ReleaseAsset
void
Releases the first audio clips in the entity
void
Releases the audio clip in the entity's clip list by index
<IList<AudioClip>>
id
<AudioClip>
id
<AudioClip>
id, int index
id
id
id, int index