O'Reilly logo

Learning C# by Developing Games with Unity 3D Beginner's Guide by Terry Norton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required