CodeBlanks Logo Icon CodeBlanks

What is an editor script?

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 development

The 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

Player.cs
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

Player.cs
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

Question
using ____;
Answer
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

All lessons in Expert