Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Unity Game Development Blueprints
  • Table Of Contents Toc
  • Feedback & Rating feedback
Unity Game Development Blueprints

Unity Game Development Blueprints

By : John P. Doran
4 (6)
close
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
close
10
Index

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

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
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

Delete Note

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

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY