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

Chapter 3. Creating Custom Inspectors

When you've worked on a Unity project for a long time, you know that the bigger your scripts get, the more unwieldy they become; all your public variables take up space in the Inspector window, and as they accumulate, they begin to convert into one giant and scary monster.

Sometimes, organization is the trick, like separating these variables in logic groups in your MonoBehaviour class, but the approach is not always enough to make inspectors user friendly.

To solve this problem, Unity allows us to create custom inspectors for our scripts, so we can define how our exposed variables and their properties should look in the Inspector window.

Here, you will learn how to have a custom inspector up and running by creating one for the Level class in Run & Jump.

In this chapter, we will cover the following topics:

  • The CustomEditor attribute

  • Inspector messages

  • Creating a GUI

  • Using layouts

  • Property Drawers and Decorator Drawers

  • The SerializedObject and SerializedProperty...