







![]() |
ClockStone Audio Toolkit for Unity - Documentation |
AudioController Class |
Members Example See Also Send Feedback |
![]() |
The audio managing class used to define and play audio items and categories.
Namespace: (Default Namespace)
Assembly: AudioToolkit (in AudioToolkit.dll) Version: 8.0.0.0 (8.0.0.0)
Syntax
C# |
---|
public class AudioController : SingletonMonoBehaviour<AudioController>, ISerializationCallbackReceiver |
Remarks
At least one instance of an AudioController must exist in each scene using the Audio Toolkit. Usually there is
exactly one controller, but you can have additional controllers if they are marked as such (in the Unity insepector, see isAdditionalAudioController)
There a two options when setting up an AudioController. Either you can specify all audio files that are used in your
entire project in one single AudioController. Then add this AudioController to your initial scene and set
it persistent from within the inspector, so it will survive when a new scene is loaded. This way all audios
are accessible from within your entire application. If you have a lot of audio files though, this may lead
to a lengthy loading time and will have a rather large memory footprint. To avoid this, you can alternatively
set up a specific AudioController for each scene which only contains those audio files needed in the particular
scene.
Examples
Once you have defined your audio categories and items in the Unity inspector you can play music and sound effects
very easily:
![]() | |
---|---|
AudioController.Play( "MySoundEffect1" ); AudioController.Play( "MySoundEffect2", new Vector3( posX, posY, posZ ) ); AudioController.PlayMusic( "MusicTrack1" ); AudioController.SetCategoryVolume( "Music", 0.5f ); AudioController.PauseMusic(); |
Inheritance Hierarchy
System..::..Object
Object
Component
Behaviour
MonoBehaviour
(Default Namespace)..::..SingletonMonoBehaviour<(Of <(<'AudioController>)>)>
(Default Namespace)..::..AudioController
Object
Component
Behaviour
MonoBehaviour
(Default Namespace)..::..SingletonMonoBehaviour<(Of <(<'AudioController>)>)>
(Default Namespace)..::..AudioController