If you wish to test the classes you just wrote in your instance of Unity, then you should go through the following steps:
- Create a new empty Unity scene called Init.
- In the Init scene, add an empty GameObject and attach the GameManager class to it.
- Create several empty Unity scenes, as many as you wish.
- In Build Settings under the File menu, add the Init scene at index 0:
Figure 4.3 – Build Settings
- Then add your new empty Unity scenes to the Build Settings list, as many as you wish.
If you now start the Init scene, you should see a GUI button named Next Scene as in the following screenshot:
Figure 4.4 – Screenshot of the code example in action
If you click on the Next Scene button, you will cycle through each of the scenes you added in Build Settings, and the GUI will persist onscreen. If you stop running the game, you should see in the console log the duration of your session. If you try to add additional GameManagers...