What is an editor script?
- Game Development course
- Expert
- Lesson 31/47
- 4 min
Learn to write Unity-specific tools with an Editor class.
Editor Scripts and the UnityEditor Namespace
To write developer tools that run directly inside the editor itself rather than during gameplay, the UnityEditor namespace is used. These scripts are placed inside special project folders named Editor so they are stripped when compiling final game builds.
using UnityEditor;
using UnityEngine;
// Code inside Editor folders runs only during developmentThe Editor Class and Custom Tools
Unity's base Editor class is extended to control editor-side behaviors of components or objects. Developers author level generation tools, batch asset processors, or custom debugging utilities using this foundation.
// Editor tools automate development workflows
Debug.Log("Editor tool executed");Practice Verify Editor Mode
Check if (Editor.isEditor) and if true, print Debug.Log("Editor modu aktif");.
Starter code
using System;
public static class Editor
{
public static bool isEditor = true;
}
public static class Debug
{
public static void Log(object message) => Console.WriteLine(message);
}
public class Program
{
public static void Main()
{
// Editor modunu kontrol et ve mesaj yazdir
}
}Sample solution
using System;
public static class Editor
{
public static bool isEditor = true;
}
public static class Debug
{
public static void Log(object message) => Console.WriteLine(message);
}
public class Program
{
public static void Main()
{
if (Editor.isEditor)
{
Debug.Log("Editor modu aktif");
}
}
}Expected output
Editor modu aktif
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 In Unity, which special folder must editor scripts be placed inside so they are excluded from the game build and only run in the development environment?
- Plugins
- Resources
- Editor Correct answer
- StreamingAssets
Explanation: Scripts located inside folders named Editor are excluded from game builds and only execute in the Unity editor.
2 UnityEditor Namespace
using ____;
using UnityEditor;
Explanation: To author editor tools, the UnityEditor namespace is imported.
3 Editor Basics Matching
| Term | Meaning |
|---|---|
UnityEditor |
Namespace with editor classes and tools |
Editor klasörü |
Folder for editor-only scripts |
Editor sınıfı |
Base class for custom editor behaviors |
Build |
Game build excluding editor scripts |