In the last tutorial, we used the auto-naming method to have AC play voice files according to a naming convention. These voice files are placed in an Assets subfolder named Resources for automatic retrieval at runtime.
However, while this method is convenient for getting up-and-running quickly, it is not the best choice for performance. It is instead more efficient to rely on Unity's Addressables system, which is faster at retreiving asset files at runtime.
Addressables are an advanced topic of Unity, and this tutorials assumes a prior working knowledge of their usage. The first step is to import Unity's Addressables system into your project. This can be done from Unity's Package Manager.
Next, we must tell AC that the Addressables package is present, so that it can safely compile Addressable-specific code. To do this, naviate to your game's Player settings (choose Edit -> Project settings... from the top toolbar, and then select Player). Then, under the Other tab, add the text AddressableIsPresent into the Scripting Define Symbols box:
If you have other symbols in this box, you can separate them with colon (;) characters.
Next, navigate to AC's Speech Manager, and set the Reference speech files field to By Addressable. If you then select a speech line within the Gathered text panel underneath, you'll then see that it has an Addressable field:
This is the expected Addressable Key for that line. We can set an Addressable Key for an audio asset by checking Addressable at the top of its Inspector, causing the Key box to appear. By default, this will be the full filename and filepath of the asset:
Rename this to match that listed in the Speech Manager:
Addressables assets can't exist in Resources folders - but Unity will move them for you automatically if this is the case.
If you are switching from the previous tutorial's By Naming Convention option, so that their existing filenames match the required keys, you can also mass-set your Addressable keys by selecting them in the Addressables Groups window and choosing Simplify Addressble Name from the context menu.
You can now test the game in the Editor to check that speech audio is being gotten from the Addressables system. For builds, you'll need to build your Addressable bundle, which can be done by choosing Build -> New Build -> Default Build Script from the Addressables Groups window.
More details on building Addressbles builds can be found on Unity's website here.