Manager Classes in Unity

Valdarix Games
2 min readMay 19, 2021

Static classes to manage cross talk

Basic setup of game manager

Manager classes allow us to create middle men that allow our scripts to operate independently from one another. For example, yesterdays article utilized the GameManager class to allow several different scripts to know if the player had a keycard or not without any of the other scripts knowing about each other.

This is the power of a manager class. We define them as static instances that we can interact with from any number of other scripts in our game without the need to create a reference in each script. Below is the rest of my current GameManager.

Part 2

This second part includes a couple of setup tasks, like the all important Awake() initialization of the GameManager instance. It also sets up any container variables the manager might need to use. In update we are checking for the player to skip the cutscene and we have the GameOver method called if the player is caught by a guard or camera.

Part 3

Part 3 has setup for WinLevel and LevelStart, these can be called from any script so we don’t have to repeat code for every instance that we might need to trigger level start.

You will also notice that the Game Manager is communicating with another manager class, the audio manager, which is set the same way.

Tomorrow we will dig into the Singleton Game Design pattern (which is what this actually is) and discuss the pros and cons.

--

--

Valdarix Games

Turning my passion for video games and software development experience into a focus on video game development.