Book Image

Extending Unity with Editor Scripting

Book Image

Extending Unity with Editor Scripting

Overview of this book

Table of Contents (18 chapters)
Extending Unity with Editor Scripting
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Customizing the Scene View


In this section we are going to take a look how to create a custom GUI in the Scene View and change its default behavior.

Using the OnSeceneGUI message method

To start rendering a GUI in Scene View, we are going to make use of a message method part of the Editor class, OnSeceneGUI.

In terms of GUI creation, we can make use of all the techniques we learned in the previous chapters working with custom inspectors and editor windows. In this case, we are going to use a toolbar component like the one used in the Palette window to simulate the tabs.

To see how this works, we are going to create a toolbar attached to the left top corner of the scene view. Each item of this toolbar will be one of the possible modes.

Let's add this method with the following code inside the LevelInspector class:

private void DrawModeGUI() {
    List<Mode> modes = EditorUtils.GetListFromEnum<Mode>();
    List<string> modeLabels = new List<string>();
    foreach(Mode mode...