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

Get Unity Game Development Blueprints 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.