Creating an Audio Manager in Unity
Jun 28, 2021
Objective: Create an audio manager that other classes can access to play and/or stop audio clips.
Much like a game manager, we’ll only need one instance of an audio manager, so we’ll use a singleton pattern. We’ll create two public methods for other scripts to access: PlayClip and StopClip.
In the example below, our VoiceOverTrigger script will access the PlayClip method.
And here, in the GameManager, we’ll allow the player to stop a voice-over hint from playing by pressing the X key.