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 – adding/removing walls at runtime

Now that our level editor will be able to load in this data, we now want to have a way to actually modify what we see onscreen. To do this, we'll need to create a GUI interface and functionality for our level editor.

  1. The first thing we need to do is add a variable to keep track of what item we want to spawn:
    //The object we are currently looking to spawn
    Transform toCreate;
  2. Now, we need to initialize this variable inside our Start function:
    toCreate = tiles[0];
  3. Next, we need to update our Update function and then explain how it's working, as follows:
    void Update() { // Left click - Create object if (Input.GetMouseButton(0) && GUIUtility.hotControl==0) { Vector3 mousePos = Input.mousePosition; //Set the ...

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