Game Manager.. One Manager to Rule them All.
<p>So we are getting to a point in our game where there are stats and bits of information that many of the other scripts need to know about. But it would be a waste of space and resources to go through and make sure that all those scripts have the needed variable to handle the information and that it is constantly kept up to date and matching all the other copies in other scripts. This is where our GameManager class comes in.</p>
<p>For now, the GameManager will be responsible for knowing if the Game is Over and handling player input for things that don’t pertain to controlling the player’s ship, such as restarting the game. But how do we talk to the GameManager without having to set up a reference to it in all the other scripts.</p>
<p>That is where the Singleton design pattern comes into play. A Singleton is a class/script that exists only once in your game and there are no other copies of it being made or referenced. Such classes can be the GameManager, the UIManager, or any other Manager class that you will only have once in the game. This allows us to set a static reference in the Singleton class that all other scripts will be able to see without having a dedicated reference for. Let’s take a look.</p>
<p><a href="https://foxxthom.medium.com/game-manager-one-manager-to-rule-them-all-1c06afa72b23"><strong>Click Here</strong></a></p>