O'Reilly logo

Unity Game Development Blueprints by John P. Doran

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

Level editor – toggling editor, GUI, and selecting additional tiles

Now that we have the basic functionality in, it wouldn't be that enjoyable if all we could do was add and remove walls. We also want to be able to spawn collectibles and change the player's starting location. Let's work on that next:

  1. Back in MonoDevelop in the LevelEditor class, we're going to want to first add in an OnGUI function to display the types of things we can create:
    void OnGUI()
    {
      GUILayout.BeginArea(new Rect(Screen.width - 110, 20, 100, 800));
      foreach(Transform item in tiles)
      {
        if (GUILayout.Button (item.name))
        {
          toCreate = item;
          
        }
      }
      GUILayout.EndArea();
    }
  2. Next, inside our GameController class, add the following code to our Update function (create the function as well ...

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