Manager Classes in Unity

This article will show how to create a Game Manager, an Audio Manager, and a UI Manager class. We will use these classes to control the intro and win cutscenes, audio for the game, and UI.

Since these classes need to be accessed across scripts for easy use, we will make them Singletons using a Mono Singleton.

The Game Manager will know if the Player has collected the required keycard and control skipping cutscenes. To change scenes and control the cutscene Timeline, we need to use the UnityEngine SceneManagement and Playables namespaces. The GameManager script has a reference to the starting cutscene to make sure it is enabled, a bool for if the Player has the keycard, and a Playable Director to control the Timeline.

We play the cutscene in Start and skip to the end if the ‘ S ’ key is pressed in Update. There is a method to change the keycard bool, check the bool, reload the level, and quit the game.

We are using the Game Manager Instance to check if the win cutscene should play.

The Audio Manager will control the voiceovers, sound effects, and background music of the game. Therefore, the Audio Manager needs variables for the music and voiceover Audio Sources to control what clip they play and when to start playing. It also needs a variable for the background music clip since the Audio Source is used for all music.

Hooking up the music clip and Audio Sources.

Use of the Audio Manager Instance to play the triggered voiceover clip.

The UI Manager will handle the Quit and Restart buttons and communicate to the Game Manager that they have been pressed.

Hooking up the button OnClick Events to the UI Manager methods.

Unity Developer, Software Engineer, Game Developer