Creating Manager Classes in Unity
Within a game big or small, it becomes necessary to have a class that allows you to control the game itself, we’re talking about the state of the game rather than the UI or audio.
In Unity, we can define these classes through c# scripts and assign them to empty GameObjects with the same name, within the game scene.
Each manager class deals specifically with its field of expertise.
When we create one of these classes we always define a static variable with the same type as the class itself, to create what will be its instance. This will allow us to call it from outside without having to use the ‘Find’ and ‘GetComponent’ instructions.
But we can’t allow this instance to be modifiable so we build a public property of the class that allows us to call it but not to modify it.
The foundation of this system is the design pattern called Singleton that together with the Properties I will deepen later.