# PopupWindow

> Class used to display popup windows that inherit from PopupWindowContent.

## Definition

* **Type:** Class
* **Namespace:** [UnityEditor](/engine/6000.0/script-reference/unityeditor.md)
* **Assembly:** UnityEditor
* **Inherits from:** [EditorWindow](/engine/6000.0/script-reference/unityeditor/editorwindow.md)

```csharp
public class PopupWindow : EditorWindow
```

## Remarks

Popup Windows are borderless, and not draggable or resizable. They also will automatically close when they lose focus. They are intended to show short-lived information or options.

An example of a Popup window in the editor is the "Scene View Effects" options, in the Editor's Scene View toolbar:

![PopupExampleSceneViewFX (PopupWindow)](/api/media?file=/engine/6000.0/media/images/PopupExampleSceneViewFX.png)

Below is an example of a custom popup window which is displayed via a button in an editor window. The Popup has three toggle values, and will automatically close when it loses focus. The example is given as two scripts. The first defines an editor window that can be opened via a menu item. That editor window has a button which shows the popup. The second script defines the contents of the popup itself as a separate class.

First, this is the code for the simple editor window which launches the popup:

```csharp
using UnityEngine;
using UnityEditor;

public class EditorWindowWithPopup : EditorWindow
{
    // Add menu item
    [MenuItem("Examples/Popup Example")]
    static void Init()
    {
        EditorWindow window = EditorWindow.CreateInstance<EditorWindowWithPopup>();
        window.Show();
    }

    Rect buttonRect;
    void OnGUI()
    {
        {
            GUILayout.Label("Editor window with Popup example", EditorStyles.boldLabel);
            if (GUILayout.Button("Popup Options", GUILayout.Width(200)))
            {
                PopupWindow.Show(buttonRect, new PopupExample());
            }
            if (Event.current.type == EventType.Repaint) buttonRect = GUILayoutUtility.GetLastRect();
        }
    }
}
```

Next, this is the code for the popup itself:

```csharp
using UnityEngine;
using UnityEditor;

public class PopupExample : PopupWindowContent
{
    bool toggle1 = true;
    bool toggle2 = true;
    bool toggle3 = true;

    public override Vector2 GetWindowSize()
    {
        return new Vector2(200, 150);
    }

    public override void OnGUI(Rect rect)
    {
        GUILayout.Label("Popup Options Example", EditorStyles.boldLabel);
        toggle1 = EditorGUILayout.Toggle("Toggle 1", toggle1);
        toggle2 = EditorGUILayout.Toggle("Toggle 2", toggle2);
        toggle3 = EditorGUILayout.Toggle("Toggle 3", toggle3);
    }

    public override void OnOpen()
    {
        Debug.Log("Popup opened: " + this);
    }

    public override void OnClose()
    {
        Debug.Log("Popup closed: " + this);
    }
}
```

Each of these should be saved as separate files named after their class name. Neither are behaviours, so you do not need to place them on a gameobject. Once they are in your project, try it by going to the new "Example" menu and selecting Popup Example. Then click the button in the new editor window to reveal the popup options window.

![PopupExampleCustom (PopupWindow)](/api/media?file=/engine/6000.0/media/images/PopupExampleCustom.png).

## Static Fields

| Value                                                                                                                   | Description                                                                  |
| ----------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| [invalidSizeLabelUssClassName](/engine/6000.0/script-reference/unityeditor/popupwindow/invalidsizelabelussclassname.md) | USS class name for the label displayed when the content has an invalid size. |

## Methods

| Method                                                                            | Description                                                                                                    |
| --------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| [OnDisable](/engine/6000.0/script-reference/unityeditor/popupwindow/ondisable.md) | See [ScriptableObject.OnEnable()](/engine/6000.0/script-reference/unityengine/scriptableobject/onenable.md).   |
| [OnEnable](/engine/6000.0/script-reference/unityeditor/popupwindow/onenable.md)   | See [ScriptableObject.OnDisable()](/engine/6000.0/script-reference/unityengine/scriptableobject/ondisable.md). |

## Static Methods

| Method                                                                  | Description                                     |
| ----------------------------------------------------------------------- | ----------------------------------------------- |
| [Show](/engine/6000.0/script-reference/unityeditor/popupwindow/show.md) | Show a popup with the given PopupWindowContent. |

## Inheritance

**Inherited Members:**

* [EditorWindow.BeginWindows()](/engine/6000.0/script-reference/unityeditor/editorwindow/beginwindows.md)
* [EditorWindow.EndWindows()](/engine/6000.0/script-reference/unityeditor/editorwindow/endwindows.md)
* [EditorWindow.ShowNotification(GUIContent)](/engine/6000.0/script-reference/unityeditor/editorwindow/shownotification.md#shownotification\(guicontent\))
* [EditorWindow.ShowNotification(GUIContent, double)](/engine/6000.0/script-reference/unityeditor/editorwindow/shownotification.md#shownotification\(guicontent-double\))
* [EditorWindow.RemoveNotification()](/engine/6000.0/script-reference/unityeditor/editorwindow/removenotification.md)
* [EditorWindow.ShowTab()](/engine/6000.0/script-reference/unityeditor/editorwindow/showtab.md)
* [EditorWindow.Focus()](/engine/6000.0/script-reference/unityeditor/editorwindow/focus.md)
* [EditorWindow.ShowUtility()](/engine/6000.0/script-reference/unityeditor/editorwindow/showutility.md)
* [EditorWindow.ShowPopup()](/engine/6000.0/script-reference/unityeditor/editorwindow/showpopup.md)
* [EditorWindow.ShowModalUtility()](/engine/6000.0/script-reference/unityeditor/editorwindow/showmodalutility.md)
* [EditorWindow.ShowAsDropDown(Rect, Vector2)](/engine/6000.0/script-reference/unityeditor/editorwindow/showasdropdown.md)
* [EditorWindow.Show()](/engine/6000.0/script-reference/unityeditor/editorwindow/show.md#show\(\))
* [EditorWindow.Show(bool)](/engine/6000.0/script-reference/unityeditor/editorwindow/show.md#show\(bool\))
* [EditorWindow.ShowAuxWindow()](/engine/6000.0/script-reference/unityeditor/editorwindow/showauxwindow.md)
* [EditorWindow.ShowModal()](/engine/6000.0/script-reference/unityeditor/editorwindow/showmodal.md)
* [EditorWindow.GetWindow(Type, bool, string, bool)](/engine/6000.0/script-reference/unityeditor/editorwindow/getwindow.md)
* [EditorWindow.GetWindowWithRect(Type, Rect, bool, string)](/engine/6000.0/script-reference/unityeditor/editorwindow/getwindowwithrect.md)
* [EditorWindow.GetWindow\<T>()](/engine/6000.0/script-reference/unityeditor/editorwindow/getwindow.md#getwindowt\(\))
* [EditorWindow.GetWindow\<T>(bool)](/engine/6000.0/script-reference/unityeditor/editorwindow/getwindow.md#getwindowt\(bool\))
* [EditorWindow.GetWindow\<T>(bool, string)](/engine/6000.0/script-reference/unityeditor/editorwindow/getwindow.md#getwindowt\(bool-string\))
* [EditorWindow.GetWindow\<T>(string)](/engine/6000.0/script-reference/unityeditor/editorwindow/getwindow.md#getwindowt\(string\))
* [EditorWindow.GetWindow\<T>(string, bool)](/engine/6000.0/script-reference/unityeditor/editorwindow/getwindow.md#getwindowt\(string-bool\))
* [EditorWindow.GetWindow\<T>(bool, string, bool)](/engine/6000.0/script-reference/unityeditor/editorwindow/getwindow.md#getwindowt\(bool-string-bool\))
* [EditorWindow.GetWindow\<T>(Type\[\])](/engine/6000.0/script-reference/unityeditor/editorwindow/getwindow.md#getwindowt\(type\))
* [EditorWindow.GetWindow\<T>(string, Type\[\])](/engine/6000.0/script-reference/unityeditor/editorwindow/getwindow.md#getwindowt\(string-type\))
* [EditorWindow.GetWindow\<T>(string, bool, Type\[\])](/engine/6000.0/script-reference/unityeditor/editorwindow/getwindow.md#getwindowt\(string-bool-type\))
* [EditorWindow.CreateWindow\<T>(Type\[\])](/engine/6000.0/script-reference/unityeditor/editorwindow/createwindow.md#createwindowt\(type\))
* [EditorWindow.CreateWindow\<T>(string, Type\[\])](/engine/6000.0/script-reference/unityeditor/editorwindow/createwindow.md#createwindowt\(string-type\))
* [EditorWindow.HasOpenInstances\<T>()](/engine/6000.0/script-reference/unityeditor/editorwindow/hasopeninstances.md)
* [EditorWindow.FocusWindowIfItsOpen(Type)](/engine/6000.0/script-reference/unityeditor/editorwindow/focuswindowifitsopen.md)
* [EditorWindow.FocusWindowIfItsOpen\<T>()](/engine/6000.0/script-reference/unityeditor/editorwindow/focuswindowifitsopen.md)
* [EditorWindow.GetWindowWithRect\<T>(Rect)](/engine/6000.0/script-reference/unityeditor/editorwindow/getwindowwithrect.md#getwindowwithrectt\(rect\))
* [EditorWindow.GetWindowWithRect\<T>(Rect, bool)](/engine/6000.0/script-reference/unityeditor/editorwindow/getwindowwithrect.md#getwindowwithrectt\(rect-bool\))
* [EditorWindow.GetWindowWithRect\<T>(Rect, bool, string)](/engine/6000.0/script-reference/unityeditor/editorwindow/getwindowwithrect.md#getwindowwithrectt\(rect-bool-string\))
* [EditorWindow.GetWindowWithRect\<T>(Rect, bool, string, bool)](/engine/6000.0/script-reference/unityeditor/editorwindow/getwindowwithrect.md#getwindowwithrectt\(rect-bool-string-bool\))
* [EditorWindow.SaveChanges()](/engine/6000.0/script-reference/unityeditor/editorwindow/savechanges.md)
* [EditorWindow.DiscardChanges()](/engine/6000.0/script-reference/unityeditor/editorwindow/discardchanges.md)
* [EditorWindow.Close()](/engine/6000.0/script-reference/unityeditor/editorwindow/close.md)
* [EditorWindow.Repaint()](/engine/6000.0/script-reference/unityeditor/editorwindow/repaint.md)
* [EditorWindow.SendEvent(Event)](/engine/6000.0/script-reference/unityeditor/editorwindow/sendevent.md)
* [EditorWindow.GetExtraPaneTypes()](/engine/6000.0/script-reference/unityeditor/editorwindow/getextrapanetypes.md)
* [EditorWindow.TryGetOverlay(string, Overlay)](/engine/6000.0/script-reference/unityeditor/editorwindow/trygetoverlay.md)
* [EditorWindow.OnBackingScaleFactorChanged()](/engine/6000.0/script-reference/unityeditor/editorwindow/onbackingscalefactorchanged.md)
* [EditorWindow.dataModeController](/engine/6000.0/script-reference/unityeditor/editorwindow/datamodecontroller.md)
* [EditorWindow.rootVisualElement](/engine/6000.0/script-reference/unityeditor/editorwindow/rootvisualelement.md)
* [EditorWindow.overlayCanvas](/engine/6000.0/script-reference/unityeditor/editorwindow/overlaycanvas.md)
* [EditorWindow.wantsMouseMove](/engine/6000.0/script-reference/unityeditor/editorwindow/wantsmousemove.md)
* [EditorWindow.wantsMouseEnterLeaveWindow](/engine/6000.0/script-reference/unityeditor/editorwindow/wantsmouseenterleavewindow.md)
* [EditorWindow.wantsLessLayoutEvents](/engine/6000.0/script-reference/unityeditor/editorwindow/wantslesslayoutevents.md)
* [EditorWindow.autoRepaintOnSceneChange](/engine/6000.0/script-reference/unityeditor/editorwindow/autorepaintonscenechange.md)
* [EditorWindow.maximized](/engine/6000.0/script-reference/unityeditor/editorwindow/maximized.md)
* [EditorWindow.hasFocus](/engine/6000.0/script-reference/unityeditor/editorwindow/hasfocus.md)
* [EditorWindow.docked](/engine/6000.0/script-reference/unityeditor/editorwindow/docked.md)
* [EditorWindow.focusedWindow](/engine/6000.0/script-reference/unityeditor/editorwindow/focusedwindow.md)
* [EditorWindow.mouseOverWindow](/engine/6000.0/script-reference/unityeditor/editorwindow/mouseoverwindow.md)
* [EditorWindow.hasUnsavedChanges](/engine/6000.0/script-reference/unityeditor/editorwindow/hasunsavedchanges.md)
* [EditorWindow.saveChangesMessage](/engine/6000.0/script-reference/unityeditor/editorwindow/savechangesmessage.md)
* [EditorWindow.minSize](/engine/6000.0/script-reference/unityeditor/editorwindow/minsize.md)
* [EditorWindow.maxSize](/engine/6000.0/script-reference/unityeditor/editorwindow/maxsize.md)
* [EditorWindow.titleContent](/engine/6000.0/script-reference/unityeditor/editorwindow/titlecontent.md)
* [EditorWindow.position](/engine/6000.0/script-reference/unityeditor/editorwindow/position.md)
* [EditorWindow.windowFocusChanged](/engine/6000.0/script-reference/unityeditor/editorwindow/windowfocuschanged.md)
* [ScriptableObject.CreateInstance(string)](/engine/6000.0/script-reference/unityengine/scriptableobject/createinstance.md#createinstance\(string\))
* [ScriptableObject.CreateInstance(Type)](/engine/6000.0/script-reference/unityengine/scriptableobject/createinstance.md#createinstance\(type\))
* [ScriptableObject.CreateInstance\<T>()](/engine/6000.0/script-reference/unityengine/scriptableobject/createinstance.md)
* [Object.GetInstanceID()](/engine/6000.0/script-reference/unityengine/object/getinstanceid.md)
* [Object.GetHashCode()](/engine/6000.0/script-reference/unityengine/object/gethashcode.md)
* [Object.InstantiateAsync\<T>(T)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Transform, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Vector3, Quaternion, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Vector3, Quaternion, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>, InstantiateParameters, CancellationToken)](/engine/6000.0/script-reference/unityengine/object/instantiateasync.md)
* [Object.Instantiate(Object, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-vector3-quaternion\))
* [Object.Instantiate(Object, Vector3, Quaternion, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-vector3-quaternion-transform\))
* [Object.Instantiate(Object)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object\))
* [Object.Instantiate(Object, Scene)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-scene\))
* [Object.Instantiate\<T>(T, InstantiateParameters)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion, InstantiateParameters)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate(Object, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-transform\))
* [Object.Instantiate(Object, Transform, bool)](/engine/6000.0/script-reference/unityengine/object/instantiate.md#instantiate\(object-transform-bool\))
* [Object.Instantiate\<T>(T)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Transform)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Transform, bool)](/engine/6000.0/script-reference/unityengine/object/instantiate.md)
* [Object.Destroy(Object, float)](/engine/6000.0/script-reference/unityengine/object/destroy.md)
* [Object.DestroyImmediate(Object, bool)](/engine/6000.0/script-reference/unityengine/object/destroyimmediate.md)
* [Object.FindObjectsByType(Type, FindObjectsSortMode)](/engine/6000.0/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytype\(type-findobjectssortmode\))
* [Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)](/engine/6000.0/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytype\(type-findobjectsinactive-findobjectssortmode\))
* [Object.DontDestroyOnLoad(Object)](/engine/6000.0/script-reference/unityengine/object/dontdestroyonload.md)
* [Object.FindObjectsByType\<T>(FindObjectsSortMode)](/engine/6000.0/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytypet\(findobjectssortmode\))
* [Object.FindObjectsByType\<T>(FindObjectsInactive, FindObjectsSortMode)](/engine/6000.0/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytypet\(findobjectsinactive-findobjectssortmode\))
* [Object.FindFirstObjectByType\<T>()](/engine/6000.0/script-reference/unityengine/object/findfirstobjectbytype.md#findfirstobjectbytypet\(\))
* [Object.FindAnyObjectByType\<T>()](/engine/6000.0/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytypet\(\))
* [Object.FindFirstObjectByType\<T>(FindObjectsInactive)](/engine/6000.0/script-reference/unityengine/object/findfirstobjectbytype.md#findfirstobjectbytypet\(findobjectsinactive\))
* [Object.FindAnyObjectByType\<T>(FindObjectsInactive)](/engine/6000.0/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytypet\(findobjectsinactive\))
* [Object.FindFirstObjectByType(Type)](/engine/6000.0/script-reference/unityengine/object/findfirstobjectbytype.md#findfirstobjectbytype\(type\))
* [Object.FindAnyObjectByType(Type)](/engine/6000.0/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytype\(type\))
* [Object.FindFirstObjectByType(Type, FindObjectsInactive)](/engine/6000.0/script-reference/unityengine/object/findfirstobjectbytype.md#findfirstobjectbytype\(type-findobjectsinactive\))
* [Object.FindAnyObjectByType(Type, FindObjectsInactive)](/engine/6000.0/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytype\(type-findobjectsinactive\))
* [Object.ToString()](/engine/6000.0/script-reference/unityengine/object/tostring.md)
* [Object.name](/engine/6000.0/script-reference/unityengine/object/name.md)
* [Object.hideFlags](/engine/6000.0/script-reference/unityengine/object/hideflags.md)

### Operators

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