Game manager classes will be a constant facet of any project you develop in the future, so let's learn how to properly create one, as follows:
- Create a new C# script in the Scripts folder and name it GameBehavior.
Usually, this script would be named GameManager, but Unity reserves that name for its uses. If you ever create a script and a cogwheel icon shows up next to its name instead of the C# file icon, that tells you it's restricted.
- Create a new empty game object in the Hierarchy by using Create | Create Empty, and name it GameManager.
- Attach GameBehavior.cs to the GameManager object, as illustrated in the following screenshot:
Manager scripts, and other non-game files, are set up on empty objects to put them in the scene, even though they don't interact with the actual 3D space.
- Add the following code to GameBehavior:
public class...