Creating the base for an editor window
In this section, we will create the base code to get an editor window up and running in Unity.
Using the EditorWindow class
The EditorWindow
class is part of the UnityEditor
namespace and must be extended to any class used to create editor windows.
Note
To use the EditorWindow
class, you must place your script inside an Editor
folder, or in a folder nested inside an Editor
folder.
Create a script called PaletteWindow.cs
inside the folder Tools/LevelCreator/Editor
, and then add the following code:
using UnityEngine; using UnityEditor; namespace RunAndJump.LevelCreator { public class PaletteWindow : EditorWindow { public static PaletteWindow instance; public static void ShowPalette () { instance = (PaletteWindow) EditorWindow.GetWindow (typeof(PaletteWindow)); instance.titleContent = new GUIContent("Palette"); } }
The GetWindow
method, which is part of the EditorWindow
class, is responsible for getting an instance of the...