Time for action – setting up nine States and three Scenes

We're going to modify some States and create some new ones. We're also going to use three Scenes.

In Unity

  1. Create three Scenes: Scene0, Scene1, and Scene2.
  2. In the menu, open File | Build Settings....
  3. Add the three Scenes to Scenes in Build.
  4. Temporarily add some GameObjects to Scene1 and Scene2 for testing.
  5. Open Scene1 and add a Cube GameObject.
  6. Open Scene2 and add two Sphere GameObjects.
  7. Reload Scene0
  8. Double-click on BeginState to edit

In MonoDevelop

  1. Edit the BeginState constructor method as follows to add an if statement for loading Scene0:
    public BeginState (StateManager managerRef)
    {
      manager = managerRef;
      if(Application.loadedLevelName != "Scene0")
        Application.LoadLevel("Scene0");
    }
  2. Make new C# classes ...

Get Learning C# by Developing Games with Unity 3D Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.