[HOWTO] How To: Use Addressables to Play Audio Files
Posted: Mon Jun 12, 2023 2:41 pm
If you don't specify otherwise, sequencer commands such as AudioWait(filename) will look in folders named Resources for filename.
If you prefer, you can put your audio files in asset bundles instead. In this case, use DialogueManager.RegisterAssetBundle() to make the asset bundle available to the Dialogue System.
Or you can use Addressables. Here's an easy way to set it up:
If you prefer, you can put your audio files in asset bundles instead. In this case, use DialogueManager.RegisterAssetBundle() to make the asset bundle available to the Dialogue System.
Or you can use Addressables. Here's an easy way to set it up:
- Import Unity's Addressables package.
- In the Dialogue System's Welcome Window, tick the USE_ADDRESSABLES checkbox.
- Name your audio files according to their entrytags.
- Move your audio files into the root of a Resources folder.
- Tick the audio files' Addressable checkboxes. Unity will ask if you want to move the audio files out of the Resources folder. Click yes. When Unity moves the files, it will set their Addressable keys to the name of the audio file. AudioWait(entrytag) will look up Addressable audio files by this key. Make sure to move the audio files into the root of Resources folders before ticking the Addressable checkbox; otherwise this process will include the path inside the Resources folder in the key.
- The Dialogue System will automatically use the audio files just like they were in Resources, except you don't need to worry about where in the project they're located. When AudioWait() is done playing, it will automatically unload the audio file from memory.