Audio Manager Breakdown

Back


Summary


The Audio Manager script is the main script for the asset. it handles the scanning and setup for audio in your project. When you first add the component to a GameObject you'll be greeted by a display similar to what you can see above. This script requires an Audio Manager File to work, it will prompt you to generate one when you first add the component.

Setup


TL:DR


Setup Breakdown


When you first add the script, it will give you the option to toggle using the static instance and the option to add an audio manager file. If you already have one in the project it will show the field for the file, otherwise the button prompting you to create one will show instead. Once the audio manager file is assigned more options will become available for you to edit.

Next you will need to populate a few fields. Starting with the sound prefab, there is one provided with the asset which you should use, stored in the prefabs folder of the asset file structure. Next you can assign mixers to play through and additional directories to scan, using the +/- buttons to add or remove fields. The directories will start from the base directory you set in the asset settings & only paths from that directory will be shown as options to add as additional directories. If there is audio in the directories it will show the audio in the clips section. If you don’t have audio there you will need to either change the currently directory to one that has audio or add an additional directory that does have audio to populate the clips section.

Once setup it’ll look something like above. The setup above is just using the assets demo music tracks for example’s sake. From this point on the audio manager is all set and ready for use. You can preview the clips with the play button next to said clip as well as hide sections with the toggles if you wish to reduce the scripts inspector footprint.

Inspector Breakdown


SettingDescription
Enable/Disable Static InstanceToggles the static instance on the audio manager script, it is off by default but can be enabled if you want to use a static instance for referencing. When toggling, the editor will take a little time to reload. Note that if you use the instance, you can only have 1 audio manager script in the game. Any extra versions will auto-destroy on enable.
Audio Manager FileThe audio manager file to read/write from.
Sound PrefabThe prefab to spawn when you call for a clip to play through the manager.
MixersThe audio mixer(s) to use when playing the clips through.
DirectoriesA collection of directories that are to be scanned, a blank field just scanned the base location. You can't have duplicates and the manager wil warn you if you do.
ClipsEach field will show a play button in green and a clip name which is the name you need to call to play the clip. You can copy directory from this field. Pressing the green button will preview the clip.