Wwise Unity Integration Documentation
Basic Tutorial For Packaging DLC

In this example we will show how to handle the simple situation where we want to separate some assets (for example a new item or character) into their own DLC asset bundle that is packaged using Addressables.

  1. Installing the Addressables Demo Scene
  2. Getting Started
  3. Loading Assets with Addressables
  4. Loading Scenes with Addressables
  5. Setting Up Addressables Hosting
  6. Updating an Addressables Asset

Installing the Addressables Demo Scene

If you have not setup the Wwise Unity addressables package in you project, please follow consult the Installation and setup instructions for the Wwise Unity Addressables package.

The official repository for the Addressables Demo Scene used in this tuorial is https://github.com/audiokinetic/WwiseUnityAddressablesDemoScene. The demo scene uses assets that are found in the Unity Demo Game so it must be installed beforehand using the Audiokinetic Launcher.

Steps:

  • Install the latest Unity Demo Game (minimum version 2021.1.0) using the Audiokinetic Launcher.
  • Clone the Wwise Unity Addressables demo scene to your computer.
  • Open the Demo Game in Unity.
  • In the Unity Package Manager, add the Wwise Unity Addressables package to the project as detailed in section Installing the Wwise Addressables Package with the Unity Package Manager and GitHub.
  • Finally, add the Wwise Unity Addressables Demo Scene package with the Add package from disk option in the Package Manager.
Note: This package cannot be added using Add package from git URL as this type of installation will prevent you from opening the scenes contained in the package.

Getting Started

For this tutorial we have created two sound effects, an event and a SoundBank in the Wwise project.

We created two GameObject prefabs with AkBank and AkEvent components : DlcAssetHighImpact and DlcAssetLowImpact. These prefabs load the DLC SoundBank and play a sound effect when they are instantiated.

We also created two scenes: AddressablesDemoScene and AddressablesSubScene. AddressablesDemoScene is a simple Unity scene with some interactive buttons so we can test loading and unloading our Addressable assets. AddressablesSubScene is a scene containing only the DlcAssetLowImpact prefab. We will use it to test loading scenes containing Wwise objects with Addressables.

Note: The AddressablesDemoScene also contains an example of using localized voices and changing languages with the Wwise Addressables package.

All of these assets, as well as the scripts described in the following section, are found in Assets\WwiseAddressablesDemoScene.

Mark these three assets as addressable by enabling the Addressable check box in their inspector.

Caution: Removing the Unity Addressables package from your project will remove the Addressable field from all assets and the state of this check box will not be preserved if you reinstall the package.

In the Addressables Groups window, you will find that these Addressable assets have been placed by default in the Default Local Group.

New groups can be created by either right-clicking the groups window and selecting Create New Group, or from the menu Create > Group > Packed Assets. Create two new groups for the DLC assets:

  • DLC_Assets for our prefabs and subscene.
  • DLC_WwiseData_Windows for our platform specific Soundbank assets.
Note: In this example we only create one additional SoundBank group for the Windows platform, but in general you should create one for each platform you plan on deploying to.
  • Move the DlcAssetHighImpact, DlcAssetLowImpact and AddressablesSubScene from the Default Local Group to the DLC_Assets group.
  • Move the platform specific DLC SoundBank asset from WwiseData_Windows to the DLC_WwiseData_Windows group.
Note: We made sure to include the strings WwiseData and the platform name Windows in the platform specific group name, so that it will be properly handled by the BuildWwiseData script when building Addressables.

In the Groups window, set the Play Mode Script to Use Existing Build and build the new Addressable packages with the Wwise Build Script (as described in Building the Project).

Now, open the AddressablesDemoScene.

Loading Assets with Addressables

In this scene there are two buttons

  • The button on the left loads and instantiates the DlcAssetHighImpact prefab using Addressables.
  • The button on the right loads and instantiates the AddressableSubScene.
    • This scene contains the DlcAssetLowImpact asset.

If you inspect the Loading DLC Assets Demo GameObject, you will see that we have created an AssetLoader object, which contains the AddressablePrefabLoader component.

using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
public class AddressablePrefabLoader : MonoBehaviour
{
public AssetReference reference;
public void Load()
{
Addressables.LoadAssetAsync<GameObject>(reference).Completed += asyncOp =>
{
if (asyncOp.Status == AsyncOperationStatus.Succeeded)
{
Instantiate(asyncOp.Result,this.transform);
}
};
}
}

This component contains an AssetReference, which we have set to be the DlcAssetHighImpact prefab in its inspector.

When we run the game and press the left button, the Load method on the AddressablePrefabLoader will be called, loading it from the DLC_Assets and instantiating the DlcAssetHighImpact prefab. Once instantiated, the AkBank component will load the SoundBank from the DLC_WwiseData_Windows asset bundle.

Loading Scenes with Addressables

If you inspect the Loading DLC Scene Demo GameObject, you will see that we have created a SceneLoader object, which contains the AddressableSceneLoader component.

using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceProviders;
using UnityEngine.SceneManagement;
public class AddressableSceneLoader : MonoBehaviour
{
public AssetReference scene;
private AsyncOperationHandle<SceneInstance> sceneHandle;
public void Awake()
{
DontDestroyOnLoad(gameObject);
}
public void LoadScene()
{
if (!sceneHandle.IsValid() )
{
scene.LoadSceneAsync( LoadSceneMode.Additive).Completed += SceneLoadComplete;
}
else
{
UnloadScene();
}
}
public void UnloadScene()
{
Addressables.UnloadSceneAsync(sceneHandle).Completed += op =>
{
if (op.Status == AsyncOperationStatus.Succeeded)
{
Debug.Log("Successfully unloaded scene");
}
};
}
private void SceneLoadComplete(AsyncOperationHandle<SceneInstance> obj)
{
sceneHandle = obj;
if (obj.Status == AsyncOperationStatus.Succeeded)
{
Debug.Log(obj.Result.Scene.name + " successfully loaded");
}
}
}

This component uses an AssetReference to hold a reference to our AddressablesSubScene. The first time the button is pressed, the LoadSceneMethod is called, which will load the scene using the LoadSceneAsync method and add it to our current scene. The second time the button is pressed, the scene will be unloaded.

The AddressablesSubScene only contains our DlcAssetLowImpact prefab, which upon instantiation will load the DLC soundbank and play its corresponding event.

Changing Languages

The third demo in this scene lets you switch between the English and French languages and play a localized voice sample. This demo uses the AkWwiseSetLocalization script. Upon pressing the green or blue buttons, this calls the AkAddressableBankManager.SetLanguageAndReloadLocalizedBanks function to change the language to English or French.

This function performs the following operations:

  • Unload all localized banks
  • Unload the Init bank
  • Set the language using AkSoundEngine.SetCurrentLanguage
  • Reload the Init bank
  • Reload the localized banks
using UnityEngine;
public class AkWwiseSetLocalization : MonoBehaviour
{
public string LanguageString;
public void SetLanguage()
{
Debug.Log($"Setting language to {LanguageString}");
AK.Wwise.Unity.WwiseAddressables.AkAddressableBankManager.Instance.SetLanguageAndReloadLocalizedBanks(LanguageString);
}
}

You can now build the AddressablesDemoScene and test the buttons to ensure that your built game is loading these assets.

Setting Up Addressables Hosting

Now we will configure Unity to serve our addressable DLC assets using its built-in hosting service. This will allow us to test updating assets using Addressables, without rebuilding our player.

First, build the AddressablesDemoScene and ensure that it works as expected. In the build window, you will have to add the AddressablesDemoScene with the Add open scenes button and select it as the scene to build.

Next we will configure Addressables Hosting, which can be accessed from the Tools menu.

Now create a Local Hosting service and enable it by selecting the Enable check box.

Open the Addressables Profiles window through the menu (Profile > Manage Profiles) and create a new profile named Editor Hosted.

Then set the Paths to the following :

  • LocalBuildPath : HostedData/[BuildTarget]
  • LocalLoadPath : http://[PrivateIpAddress]:[HostingServicePort]
  • RemoteBuildPath : HostedData/[BuildTarget]
  • RemoteLoadPath : http://[PrivateIpAddress]:[HostingServicePort]

Then, use this profile by right-clicking Editor Hosted and selecting Set Active.

Note: Consult the official documentation for more information about using Addressables hosting service.

Inspect the DLC_WwiseData_Windows group asset and ensure that its Build path and Load path have been updated.

Open your Addressable Asset Settings and enable Build Remote Catalog . Set the Build Path and Load Path to LocalBuildPath and LocalLoadPath, respectively.

Rebuild your addressable assets using the Wwise Build Script. The new adressable AssetBundles should be created in <Unity Project Path>\HostedData.

Now rebuild the AddressablesDemoScene to test that your assets are being served properly.

Open the Addressables Hosting window to view incoming requests as you run the game. The first time a button is pressed, a request should appear in the events log at the bottom of the window.

Updating an Addressables Asset

Now, we will update our DlcAssetHighImpact sound using Addressables.

First, in Wwise, adjust the imp_axe_stone_high sound sample's pitch value so that the change will be obvious. Then regenerate your SoundBanks.

Then, in the Addressables Groups window, select Build >Update a previous build. In the selection window that opens, select the addressables_content_state.bin file in AddressableAssetsData/Windows.

Finally, run your built game again (without rebuilding it). When it opens, you shoud see a request for the update catalog in the Addressables hosting window.

Then, when you press the left button, you should hear the sound effect at its new pitch height.

For more infomation about the Addressables catalog and the intended development cycle, consult the official documentation.

Note: This scripts provided in this tutorial are the minimum required to test loading assets with Addressables. You will likely want to use a more robust solution for loading assets in your project. Some more advanced examples can be found in the Unity Addressables Sample repository.
Definition: AkWwiseAcousticTexture.cs:4
Definition: AkWwiseAcousticTexture.cs:4