To create the game manager functionality, we need a script to initialize a new scene and the state manager. We also need a second scene to be added to our project, to switch between scenes (named Home and Game). Another script is required to create a button that sends the application from the home scene to the game scene. Finally, we need a game object to attach the scripts to, which we are preserving as we switch between scenes. Let's get to work!
Access the
Scripts
folder in the Project panel and create a new C# script. Name the scriptStateManager
.Double-click on the file to open it in Monodevelop.
Add the following lines to the script:
using UnityEngine; using System.Collections; public class StateManager : MonoBehaviour { private static StateManager instance public static StateManager Instance { get { if(instance == null) ...