Playing voice files from AssetBundles

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 AssetBundles, which can be loaded and unloaded at runtime dynamically.

AssetBundles are an advanced topic of Unity, and it assumes a prior working knowledge of their usage. For an official guide to AssetBundles, see Unity's own documentation here.

Assuming that your voice files are already correctly named and stored within your Resources folder, you can mass-select them to place them in an AssetBundle via the bottom of their Inspectors. Here, we've placed all our game's original-language speech audio into a bundle named original_speech:

This bundle will then need to be generated. There are several ways to generate an AssetBundle, but Unity provides a sample script on their own website here.

Note: As file retrieval is still performed by naming convention, each file within the AssetBundle must have a unique filename.

Once you have created the AssetBundle, it will need to be moved to an Assets subfolder named StreamingAssets:

The audio files can now be taken out of the Resources folder, if that's where they are.

To inform AC that we wish to use AssetBundles for voice files, navigate to the Speech Manager and enable Get speech files from AssetBundles?.

Note: This option is only available in AC v1.66 or newer, and is only visible if Auto-name speech audio files? is also checked.

Once checked, an Audio AssetBundle name field will appear for each language that allows for speech audio. Here, you must supply the name of the AssetBundle that stores audio for that language:

Selecting a speech line from the Game text panel will inform you of the expected AssetBundle and filepath for the audio:

If your game makes use of lipsyncing, lipsync files will also need to be placed in AssetBundles. These can either be the same bundles used by audio, or separate ones - but the bundle names must similarly be entered into the Lipsync AssetBundle name field(s).

Adventure Creator and this website are copyright Chris Burton, ICEBOX Studios

Go to top
Do NOT follow this link or you will be banned from the site!