Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Unity Game Development Blueprints
  • Toc
  • feedback
Unity Game Development Blueprints

Unity Game Development Blueprints

By : John P. Doran
4 (6)
close
Unity Game Development Blueprints

Unity Game Development Blueprints

4 (6)
By: John P. Doran

Overview of this book

If you want to build enticing projects with Unity, this book is for you. Readers who are familiar with the basics of how to create simple projects in Unity will have an easier time.
Table of Contents (11 chapters)
close
10
Index

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 position in the z axis to the opposite of the 
        // camera's so that the position is on the world so 
        // ScreenToWorldPoint will give us valid values.
        mousePos.z = Camera.main.transform.position.z * -1;
    
        Vector3...
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete