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:
Back in
MonoDevelopin theLevelEditorclass, we're going to want to first add in anOnGUIfunction 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(); }Next, inside our
GameControllerclass, add the following code to ourUpdatefunction (create the function as well if it doesn't exist in your current implementation, such as the example code):void Update() { if(Input.GetKeyDown("f2")) { this.gameObject.GetComponent<LevelEditor>().enabled = true; } }Now, if we...