O'Reilly logo

Extending Unity with Editor Scripting by Angelo Tadres

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

Editor scripting basics

It's time to go hands on in the creation of editor scripts so in this section we are going to explore how to start them off.

What is an editor script?

An editor script is any piece of code that uses methods from the UnityEditor namespace, and its principal objective is to create or modify functionalities in the Unity editor.

To see this working, let's start with a basic example. Create a new project in Unity and then a new script called HelloWorld.cs. Don't worry about where to place the script, we'll talk about that in a bit. Copy the following code:

using UnityEngine; using UnityEditor; public class HelloWorld { [MenuItem ("GameObject/Create HelloWorld")] private static void CreateHelloWorldGameObject () { if(EditorUtility.DisplayDialog( ...

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