# EditorWindow

> Derive from this class to create a custom Editor window.

## Definition

* **Type:** Class
* **Namespace:** [UnityEditor](/engine/6000.5/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule
* **Inherits from:** [ScriptableObject](/engine/6000.5/script-reference/unityengine/scriptableobject.md)

```csharp
[ExcludeFromObjectFactory]
public class EditorWindow : ScriptableObject
```

## Remarks

Use this class to create Editor windows that can either float independently or dock as tabs, similar to the default windows in the Unity Editor.

You can use the [MenuItem](/engine/6000.5/script-reference/unityeditor/menuitem.md) attribute to configure an Editor window to be opened in the Unity Editor menu.

When creating a custom Editor window, follow these guidelines:

* Put code dependent on UXML/USS loading in the [CreateGUI](/engine/6000.5/script-reference/unityeditor/editorwindow/creategui.md) method to ensure that all necessary assets are available.
* Keep the event registration code inside [CreateGUI](/engine/6000.5/script-reference/unityeditor/editorwindow/creategui.md) or after [CreateGUI](/engine/6000.5/script-reference/unityeditor/editorwindow/creategui.md) is called.

The following diagram shows the order of execution of an Editor window:

![UIE order of editor window (EditorWindow)](/api/media?file=/engine/6000.5/media/images/UIE-order-of-editor-window.png)

* [OnEnable](/engine/6000.5/script-reference/unityengine/scriptableobject/onenable.md): Called when the script is loaded or when the object is enabled.
* [EditorApplication.isUpdating](/engine/6000.5/script-reference/unityeditor/editorapplication/isupdating.md): If true, the Editor is currently refreshing the [AssetDatabase](/engine/6000.5/script-reference/unityeditor/assetdatabase.md).
* [CreateGUI](/engine/6000.5/script-reference/unityeditor/editorwindow/creategui.md): Generates the graphical user interface if the Editor is not updating.
* [Update](/engine/6000.5/script-reference/unityeditor/editorwindow/update.md): Called multiple times per second on all visible windows.
* [OnGUI](/engine/6000.5/script-reference/unityeditor/editorwindow/ongui.md): Called multiple times per frame for rendering and handling GUI events.
* [OnDisable](/engine/6000.5/script-reference/unityengine/scriptableobject/ondisable.md): Called when the script is disabled or the object is destroyed to finalize and clean up resources.

For an example on how to create an Editor window that reacts to user input, refer to [Create a custom Editor window with C# script](/engine/6000.5/manual/uitoolkits/uielements/uie-support-for-editor-ui/uie-how-to-create-editor-window.md).

## Examples

```csharp
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;

public class MyEditorWindow : EditorWindow
{
    [MenuItem("Examples/My Editor Window")]
    public static void ShowExample()
    {
        MyEditorWindow wnd = GetWindow<MyEditorWindow>();
        wnd.titleContent = new GUIContent("MyEditorWindow");
    }

    public void CreateGUI()
    {
        // Each editor window contains a root VisualElement object
        VisualElement root = rootVisualElement;

        // VisualElements objects can contain other VisualElement following a tree hierarchy
        Label label = new Label("Hello World!");
        root.Add(label);

        // Create button
        Button button = new Button();
        button.name = "button";
        button.text = "Button";
        root.Add(button);

        // Create toggle
        Toggle toggle = new Toggle();
        toggle.name = "toggle";
        toggle.label = "Toggle";
        root.Add(toggle);
    }
}
```

## Properties

| Property                                                                                                             | Description                                                                                                                                                                                                                                                                                                        |
| -------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [autoRepaintOnSceneChange](/engine/6000.5/script-reference/unityeditor/editorwindow/autorepaintonscenechange.md)     | Enable this property to automatically repaint the window when the [SceneView](/engine/6000.5/script-reference/unityeditor/sceneview.md) is modified.                                                                                                                                                               |
| [dataModeController](/engine/6000.5/script-reference/unityeditor/editorwindow/datamodecontroller.md)                 | An instance of [IDataModeController](/engine/6000.5/script-reference/unityeditor/idatamodecontroller.md) to handle [DataMode](/engine/6000.5/script-reference/unityeditor/datamode.md) functionalities for the current window.                                                                                     |
| [docked](/engine/6000.5/script-reference/unityeditor/editorwindow/docked.md)                                         | Returns true if EditorWindow is docked.                                                                                                                                                                                                                                                                            |
| [hasFocus](/engine/6000.5/script-reference/unityeditor/editorwindow/hasfocus.md)                                     | Returns true if EditorWindow is focused.                                                                                                                                                                                                                                                                           |
| [hasUnsavedChanges](/engine/6000.5/script-reference/unityeditor/editorwindow/hasunsavedchanges.md)                   | This property specifies whether the Editor prompts the user to save or discard unsaved changes before the window closes.                                                                                                                                                                                           |
| [maximized](/engine/6000.5/script-reference/unityeditor/editorwindow/maximized.md)                                   | Whether or not this window is maximized?                                                                                                                                                                                                                                                                           |
| [maxSize](/engine/6000.5/script-reference/unityeditor/editorwindow/maxsize.md)                                       | The maximum size of this window when it is floating or modal. The maximum size is not used when the window is docked.                                                                                                                                                                                              |
| [minSize](/engine/6000.5/script-reference/unityeditor/editorwindow/minsize.md)                                       | The minimum size of this window when it is floating or modal. The minimum size is not used when the window is docked.                                                                                                                                                                                              |
| [overlayCanvas](/engine/6000.5/script-reference/unityeditor/editorwindow/overlaycanvas.md)                           | The [OverlayCanvas](/engine/6000.5/script-reference/unityeditor/overlays/overlaycanvas.md) for this window.                                                                                                                                                                                                        |
| [position](/engine/6000.5/script-reference/unityeditor/editorwindow/position.md)                                     | The desired position of the window in screen space.                                                                                                                                                                                                                                                                |
| [rootVisualElement](/engine/6000.5/script-reference/unityeditor/editorwindow/rootvisualelement.md)                   | Retrieves the root visual element of this window hierarchy.                                                                                                                                                                                                                                                        |
| [saveChangesMessage](/engine/6000.5/script-reference/unityeditor/editorwindow/savechangesmessage.md)                 | The message that displays to the user if they are prompted to save                                                                                                                                                                                                                                                 |
| [titleContent](/engine/6000.5/script-reference/unityeditor/editorwindow/titlecontent.md)                             | The GUIContent used for drawing the title of EditorWindows.                                                                                                                                                                                                                                                        |
| [wantsLessLayoutEvents](/engine/6000.5/script-reference/unityeditor/editorwindow/wantslesslayoutevents.md)           | Specifies whether a layout pass is performed before all user events (for example, [EventType.MouseDown](/engine/6000.5/script-reference/unityengine/eventtype/mousedown.md) or [EventType.KeyDown](/engine/6000.5/script-reference/unityengine/eventtype/keydown.md)), or is only performed before repaint events. |
| [wantsMouseEnterLeaveWindow](/engine/6000.5/script-reference/unityeditor/editorwindow/wantsmouseenterleavewindow.md) | Checks whether MouseEnterWindow and MouseLeaveWindow events are received in the GUI in this Editor window.                                                                                                                                                                                                         |
| [wantsMouseMove](/engine/6000.5/script-reference/unityeditor/editorwindow/wantsmousemove.md)                         | Checks whether MouseMove events are received in the GUI in this Editor window.                                                                                                                                                                                                                                     |

## Static Properties

| Property                                                                                       | Description                                                      |
| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| [focusedWindow](/engine/6000.5/script-reference/unityeditor/editorwindow/focusedwindow.md)     | The EditorWindow which currently has keyboard focus. (Read Only) |
| [mouseOverWindow](/engine/6000.5/script-reference/unityeditor/editorwindow/mouseoverwindow.md) | The EditorWindow currently under the mouse cursor. (Read Only)   |

## Methods

| Method                                                                                                                 | Description                                                                                                                                                                                  |
| ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Awake](/engine/6000.5/script-reference/unityeditor/editorwindow/awake.md)                                             | Called as the new window is opened.                                                                                                                                                          |
| [BeginWindows](/engine/6000.5/script-reference/unityeditor/editorwindow/beginwindows.md)                               | Mark the beginning area of all popup windows.                                                                                                                                                |
| [Close](/engine/6000.5/script-reference/unityeditor/editorwindow/close.md)                                             | Close the editor window.                                                                                                                                                                     |
| [CreateGUI](/engine/6000.5/script-reference/unityeditor/editorwindow/creategui.md)                                     | CreateGUI is called when the EditorWindow's rootVisualElement is ready to be populated.                                                                                                      |
| [DiscardChanges](/engine/6000.5/script-reference/unityeditor/editorwindow/discardchanges.md)                           | Discards unsaved changes to the contents of the window.                                                                                                                                      |
| [EndWindows](/engine/6000.5/script-reference/unityeditor/editorwindow/endwindows.md)                                   | Close a window group started with [EditorWindow.BeginWindows()](/engine/6000.5/script-reference/unityeditor/editorwindow/beginwindows.md).                                                   |
| [Focus](/engine/6000.5/script-reference/unityeditor/editorwindow/focus.md)                                             | Moves keyboard focus to another EditorWindow.                                                                                                                                                |
| [GetExtraPaneTypes](/engine/6000.5/script-reference/unityeditor/editorwindow/getextrapanetypes.md)                     | Gets the extra types of EditorWindow associated with the current window.                                                                                                                     |
| [OnBackingScaleFactorChanged](/engine/6000.5/script-reference/unityeditor/editorwindow/onbackingscalefactorchanged.md) | Called when the UI scaling for this EditorWindow is changed.                                                                                                                                 |
| [OnBecameInvisible](/engine/6000.5/script-reference/unityeditor/editorwindow/onbecameinvisible.md)                     | Called after the window is removed from a container view, or is no longer visible within a tabbed collection of [EditorWindow](/engine/6000.5/script-reference/unityeditor/editorwindow.md). |
| [OnBecameVisible](/engine/6000.5/script-reference/unityeditor/editorwindow/onbecamevisible.md)                         | Called after the window is added to a container view.                                                                                                                                        |
| [OnDestroy](/engine/6000.5/script-reference/unityeditor/editorwindow/ondestroy.md)                                     | OnDestroy is called to close the EditorWindow window.                                                                                                                                        |
| [OnFocus](/engine/6000.5/script-reference/unityeditor/editorwindow/onfocus.md)                                         | Called when the window gets keyboard focus.                                                                                                                                                  |
| [OnGUI](/engine/6000.5/script-reference/unityeditor/editorwindow/ongui.md)                                             | Implement your own editor GUI here.                                                                                                                                                          |
| [OnHierarchyChange](/engine/6000.5/script-reference/unityeditor/editorwindow/onhierarchychange.md)                     | Handler for message that is sent when an object or group of objects in the hierarchy changes.                                                                                                |
| [OnInspectorUpdate](/engine/6000.5/script-reference/unityeditor/editorwindow/oninspectorupdate.md)                     | OnInspectorUpdate is called at 10 frames per second to give the inspector a chance to update.                                                                                                |
| [OnLostFocus](/engine/6000.5/script-reference/unityeditor/editorwindow/onlostfocus.md)                                 | Called when the window loses keyboard focus.                                                                                                                                                 |
| [OnProjectChange](/engine/6000.5/script-reference/unityeditor/editorwindow/onprojectchange.md)                         | Handler for message that is sent whenever the state of the project changes.                                                                                                                  |
| [OnSelectionChange](/engine/6000.5/script-reference/unityeditor/editorwindow/onselectionchange.md)                     | Called whenever the selection has changed.                                                                                                                                                   |
| [RemoveNotification](/engine/6000.5/script-reference/unityeditor/editorwindow/removenotification.md)                   | Stop showing notification message.                                                                                                                                                           |
| [Repaint](/engine/6000.5/script-reference/unityeditor/editorwindow/repaint.md)                                         | Make the window repaint. This queues a command to render the window on the next frame.                                                                                                       |
| [SaveChanges](/engine/6000.5/script-reference/unityeditor/editorwindow/savechanges.md)                                 | Performs a save action on the contents of the window.                                                                                                                                        |
| [SendEvent](/engine/6000.5/script-reference/unityeditor/editorwindow/sendevent.md)                                     | Sends an Event to a window.                                                                                                                                                                  |
| [Show](/engine/6000.5/script-reference/unityeditor/editorwindow/show.md)                                               | Show the EditorWindow window.                                                                                                                                                                |
| [ShowAsDropDown](/engine/6000.5/script-reference/unityeditor/editorwindow/showasdropdown.md)                           | Shows a window with dropdown behaviour and styling.                                                                                                                                          |
| [ShowAuxWindow](/engine/6000.5/script-reference/unityeditor/editorwindow/showauxwindow.md)                             | Show the editor window in the auxiliary window.                                                                                                                                              |
| [ShowModal](/engine/6000.5/script-reference/unityeditor/editorwindow/showmodal.md)                                     | Show modal editor window.                                                                                                                                                                    |
| [ShowModalUtility](/engine/6000.5/script-reference/unityeditor/editorwindow/showmodalutility.md)                       | Shows the EditorWindow as a floating modal window.                                                                                                                                           |
| [ShowNotification](/engine/6000.5/script-reference/unityeditor/editorwindow/shownotification.md)                       | Show a notification message.                                                                                                                                                                 |
| [ShowPopup](/engine/6000.5/script-reference/unityeditor/editorwindow/showpopup.md)                                     | Shows an Editor window using popup-style framing.                                                                                                                                            |
| [ShowTab](/engine/6000.5/script-reference/unityeditor/editorwindow/showtab.md)                                         | Shows a docked Editor window.                                                                                                                                                                |
| [ShowUtility](/engine/6000.5/script-reference/unityeditor/editorwindow/showutility.md)                                 | Show the EditorWindow as a floating utility window.                                                                                                                                          |
| [TryGetOverlay](/engine/6000.5/script-reference/unityeditor/editorwindow/trygetoverlay.md)                             | Get an [Overlay](/engine/6000.5/script-reference/unityeditor/overlays/overlay.md) with matching ID from an EditorWindow canvas.                                                              |
| [Update](/engine/6000.5/script-reference/unityeditor/editorwindow/update.md)                                           | Called multiple times per second on all visible windows.                                                                                                                                     |

## Static Methods

| Method                                                                                                   | Description                                                                           |
| -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| [CreateWindow](/engine/6000.5/script-reference/unityeditor/editorwindow/createwindow.md)                 | Creates an EditorWindow of type `T`.                                                  |
| [FocusWindowIfItsOpen](/engine/6000.5/script-reference/unityeditor/editorwindow/focuswindowifitsopen.md) | Focuses the first found EditorWindow of specified type if it is open.                 |
| [GetWindow](/engine/6000.5/script-reference/unityeditor/editorwindow/getwindow.md)                       | Returns the first EditorWindow of type `windowType` which is currently on the screen. |
| [GetWindowWithRect](/engine/6000.5/script-reference/unityeditor/editorwindow/getwindowwithrect.md)       | Returns the first EditorWindow of type `t` which is currently on the screen.          |
| [HasOpenInstances](/engine/6000.5/script-reference/unityeditor/editorwindow/hasopeninstances.md)         | Checks if an editor window is open.                                                   |

## Static Events

| Member                                                                                               | Description                                           |
| ---------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
| [windowFocusChanged](/engine/6000.5/script-reference/unityeditor/editorwindow/windowfocuschanged.md) | Called whenever the focused editor window is changed. |

## Inheritance

**Inherited Members:**

* [ScriptableObject.CreateInstance(string)](/engine/6000.5/script-reference/unityengine/scriptableobject/createinstance.md#createinstance\(string\))
* [ScriptableObject.CreateInstance(Type)](/engine/6000.5/script-reference/unityengine/scriptableobject/createinstance.md#createinstance\(type\))
* [ScriptableObject.CreateInstance\<T>()](/engine/6000.5/script-reference/unityengine/scriptableobject/createinstance.md)
* [Object.GetEntityId()](/engine/6000.5/script-reference/unityengine/object/getentityid.md)
* [Object.GetHashCode()](/engine/6000.5/script-reference/unityengine/object/gethashcode.md)
* [Object.InstantiateAsync\<T>(T)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Transform)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Vector3, Quaternion)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Transform, Vector3, Quaternion)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Vector3, Quaternion)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, Vector3, Quaternion)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>, CancellationToken)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, InstantiateParameters, CancellationToken)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, InstantiateParameters, CancellationToken)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Vector3, Quaternion, InstantiateParameters, CancellationToken)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Vector3, Quaternion, InstantiateParameters, CancellationToken)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>, InstantiateParameters, CancellationToken)](/engine/6000.5/script-reference/unityengine/object/instantiateasync.md)
* [Object.Instantiate(Object, Vector3, Quaternion)](/engine/6000.5/script-reference/unityengine/object/instantiate.md#instantiate\(object-vector3-quaternion\))
* [Object.Instantiate(Object, Vector3, Quaternion, Transform)](/engine/6000.5/script-reference/unityengine/object/instantiate.md#instantiate\(object-vector3-quaternion-transform\))
* [Object.Instantiate(Object)](/engine/6000.5/script-reference/unityengine/object/instantiate.md#instantiate\(object\))
* [Object.Instantiate(Object, Scene)](/engine/6000.5/script-reference/unityengine/object/instantiate.md#instantiate\(object-scene\))
* [Object.Instantiate\<T>(T, InstantiateParameters)](/engine/6000.5/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion, InstantiateParameters)](/engine/6000.5/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate(Object, Transform)](/engine/6000.5/script-reference/unityengine/object/instantiate.md#instantiate\(object-transform\))
* [Object.Instantiate(Object, Transform, bool)](/engine/6000.5/script-reference/unityengine/object/instantiate.md#instantiate\(object-transform-bool\))
* [Object.Instantiate\<T>(T)](/engine/6000.5/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion)](/engine/6000.5/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion, Transform)](/engine/6000.5/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Transform)](/engine/6000.5/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Transform, bool)](/engine/6000.5/script-reference/unityengine/object/instantiate.md)
* [Object.Destroy(Object, float)](/engine/6000.5/script-reference/unityengine/object/destroy.md)
* [Object.DestroyImmediate(Object, bool)](/engine/6000.5/script-reference/unityengine/object/destroyimmediate.md)
* [Object.FindObjectsByType(Type)](/engine/6000.5/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytype\(type\))
* [Object.FindObjectsByType(Type, FindObjectsInactive)](/engine/6000.5/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytype\(type-findobjectsinactive\))
* [Object.DontDestroyOnLoad(Object)](/engine/6000.5/script-reference/unityengine/object/dontdestroyonload.md)
* [Object.FindAnyObjectByType\<T>()](/engine/6000.5/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytypet\(\))
* [Object.FindAnyObjectByType\<T>(FindObjectsInactive)](/engine/6000.5/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytypet\(findobjectsinactive\))
* [Object.FindObjectsByType\<T>()](/engine/6000.5/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytypet\(\))
* [Object.FindObjectsByType\<T>(FindObjectsInactive)](/engine/6000.5/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytypet\(findobjectsinactive\))
* [Object.FindAnyObjectByType(Type)](/engine/6000.5/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytype\(type\))
* [Object.FindAnyObjectByType(Type, FindObjectsInactive)](/engine/6000.5/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytype\(type-findobjectsinactive\))
* [Object.ToString()](/engine/6000.5/script-reference/unityengine/object/tostring.md)
* [Object.name](/engine/6000.5/script-reference/unityengine/object/name.md)
* [Object.hideFlags](/engine/6000.5/script-reference/unityengine/object/hideflags.md)

### Operators

| Operator                                                                           | Description                                                             |
| ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| [operator ==](/engine/6000.5/script-reference/unityengine/object/op-equality.md)   | Compares two object references to see if they refer to the same object. |
| [bool](/engine/6000.5/script-reference/unityengine/object/op-implicit.md)          | Determines whether the object exists.                                   |
| [operator !=](/engine/6000.5/script-reference/unityengine/object/op-inequality.md) | Compares if two objects refer to a different object.                    |
