# Popup

> Make a generic popup selection field.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.7/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule

## Popup(int, string\[], GUILayoutOption\[])

Make a generic popup selection field.

```csharp
public static int Popup(int selectedIndex, string[] displayedOptions, params GUILayoutOption[] options)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the option the field shows.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): An array with the options shown in the popup. Use a slash to separate sub-items (ex. Menu/SubMenu). Use null or an empty string to add a separator. "**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                       | Description                                                 |
| ---------------------------------------------------------- | ----------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the option that has been selected by the user. |

### Remarks

Takes the currently selected index as a parameter and returns the index selected by the user.

![EditorGUILayoutPopup (Popup)](/api/media?file=/engine/6000.7/media/images/EditorGUILayoutPopup.png)

*Create a primitive depending on the option selected.*

### Examples

```csharp
using UnityEditor;
using UnityEngine;
using System.Collections;

// Creates an instance of a primitive depending on the option selected by the user.
public class EditorGUILayoutPopup : EditorWindow
{
    public string[] options = new string[] {"Cube", "Sphere", "Plane"};
    public int index = 0;
    [MenuItem("Examples/Editor GUILayout Popup usage")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUILayoutPopup));
        window.Show();
    }

    void OnGUI()
    {
        index = EditorGUILayout.Popup(index, options);
        if (GUILayout.Button("Create"))
            InstantiatePrimitive();
    }

    void InstantiatePrimitive()
    {
        switch (index)
        {
            case 0:
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Vector3.zero;
                break;
            case 1:
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.position = Vector3.zero;
                break;
            case 2:
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.transform.position = Vector3.zero;
                break;
            default:
                Debug.LogError("Unrecognized Option");
                break;
        }
    }
}
```

## Popup(int, string\[], GUIStyle, GUILayoutOption\[])

Make a generic popup selection field.

```csharp
public static int Popup(int selectedIndex, string[] displayedOptions, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the option the field shows.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): An array with the options shown in the popup. Use a slash to separate sub-items (ex. Menu/SubMenu). Use null or an empty string to add a separator. "**** (\[GUIStyle]\(/engine/6000.7/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.7/script-reference/unityengine/guistyle.md).**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                       | Description                                                 |
| ---------------------------------------------------------- | ----------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the option that has been selected by the user. |

### Remarks

Takes the currently selected index as a parameter and returns the index selected by the user.

![EditorGUILayoutPopup (Popup)](/api/media?file=/engine/6000.7/media/images/EditorGUILayoutPopup.png)

*Create a primitive depending on the option selected.*

### Examples

```csharp
using UnityEditor;
using UnityEngine;
using System.Collections;

// Creates an instance of a primitive depending on the option selected by the user.
public class EditorGUILayoutPopup : EditorWindow
{
    public string[] options = new string[] {"Cube", "Sphere", "Plane"};
    public int index = 0;
    [MenuItem("Examples/Editor GUILayout Popup usage")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUILayoutPopup));
        window.Show();
    }

    void OnGUI()
    {
        index = EditorGUILayout.Popup(index, options);
        if (GUILayout.Button("Create"))
            InstantiatePrimitive();
    }

    void InstantiatePrimitive()
    {
        switch (index)
        {
            case 0:
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Vector3.zero;
                break;
            case 1:
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.position = Vector3.zero;
                break;
            case 2:
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.transform.position = Vector3.zero;
                break;
            default:
                Debug.LogError("Unrecognized Option");
                break;
        }
    }
}
```

## Popup(int, GUIContent\[], GUILayoutOption\[])

Make a generic popup selection field.

```csharp
public static int Popup(int selectedIndex, GUIContent[] displayedOptions, params GUILayoutOption[] options)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the option the field shows.**** (\[GUIContent\[]]\(/engine/6000.7/script-reference/unityengine/guicontent)): An array with the options shown in the popup. Use a slash to separate sub-items (ex. Menu/SubMenu). Use null or an empty string to add a separator. "**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                       | Description                                                 |
| ---------------------------------------------------------- | ----------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the option that has been selected by the user. |

### Remarks

Takes the currently selected index as a parameter and returns the index selected by the user.

![EditorGUILayoutPopup (Popup)](/api/media?file=/engine/6000.7/media/images/EditorGUILayoutPopup.png)

*Create a primitive depending on the option selected.*

### Examples

```csharp
using UnityEditor;
using UnityEngine;
using System.Collections;

// Creates an instance of a primitive depending on the option selected by the user.
public class EditorGUILayoutPopup : EditorWindow
{
    public string[] options = new string[] {"Cube", "Sphere", "Plane"};
    public int index = 0;
    [MenuItem("Examples/Editor GUILayout Popup usage")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUILayoutPopup));
        window.Show();
    }

    void OnGUI()
    {
        index = EditorGUILayout.Popup(index, options);
        if (GUILayout.Button("Create"))
            InstantiatePrimitive();
    }

    void InstantiatePrimitive()
    {
        switch (index)
        {
            case 0:
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Vector3.zero;
                break;
            case 1:
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.position = Vector3.zero;
                break;
            case 2:
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.transform.position = Vector3.zero;
                break;
            default:
                Debug.LogError("Unrecognized Option");
                break;
        }
    }
}
```

## Popup(int, GUIContent\[], GUIStyle, GUILayoutOption\[])

Make a generic popup selection field.

```csharp
public static int Popup(int selectedIndex, GUIContent[] displayedOptions, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the option the field shows.**** (\[GUIContent\[]]\(/engine/6000.7/script-reference/unityengine/guicontent)): An array with the options shown in the popup. Use a slash to separate sub-items (ex. Menu/SubMenu). Use null or an empty string to add a separator. "**** (\[GUIStyle]\(/engine/6000.7/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.7/script-reference/unityengine/guistyle.md).**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                       | Description                                                 |
| ---------------------------------------------------------- | ----------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the option that has been selected by the user. |

### Remarks

Takes the currently selected index as a parameter and returns the index selected by the user.

![EditorGUILayoutPopup (Popup)](/api/media?file=/engine/6000.7/media/images/EditorGUILayoutPopup.png)

*Create a primitive depending on the option selected.*

### Examples

```csharp
using UnityEditor;
using UnityEngine;
using System.Collections;

// Creates an instance of a primitive depending on the option selected by the user.
public class EditorGUILayoutPopup : EditorWindow
{
    public string[] options = new string[] {"Cube", "Sphere", "Plane"};
    public int index = 0;
    [MenuItem("Examples/Editor GUILayout Popup usage")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUILayoutPopup));
        window.Show();
    }

    void OnGUI()
    {
        index = EditorGUILayout.Popup(index, options);
        if (GUILayout.Button("Create"))
            InstantiatePrimitive();
    }

    void InstantiatePrimitive()
    {
        switch (index)
        {
            case 0:
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Vector3.zero;
                break;
            case 1:
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.position = Vector3.zero;
                break;
            case 2:
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.transform.position = Vector3.zero;
                break;
            default:
                Debug.LogError("Unrecognized Option");
                break;
        }
    }
}
```

## Popup(string, int, string\[], GUILayoutOption\[])

Make a generic popup selection field.

```csharp
public static int Popup(string label, int selectedIndex, string[] displayedOptions, params GUILayoutOption[] options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Optional label in front of the field.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the option the field shows.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): An array with the options shown in the popup. Use a slash to separate sub-items (ex. Menu/SubMenu). Use null or an empty string to add a separator. "**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                       | Description                                                 |
| ---------------------------------------------------------- | ----------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the option that has been selected by the user. |

### Remarks

Takes the currently selected index as a parameter and returns the index selected by the user.

![EditorGUILayoutPopup (Popup)](/api/media?file=/engine/6000.7/media/images/EditorGUILayoutPopup.png)

*Create a primitive depending on the option selected.*

### Examples

```csharp
using UnityEditor;
using UnityEngine;
using System.Collections;

// Creates an instance of a primitive depending on the option selected by the user.
public class EditorGUILayoutPopup : EditorWindow
{
    public string[] options = new string[] {"Cube", "Sphere", "Plane"};
    public int index = 0;
    [MenuItem("Examples/Editor GUILayout Popup usage")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUILayoutPopup));
        window.Show();
    }

    void OnGUI()
    {
        index = EditorGUILayout.Popup(index, options);
        if (GUILayout.Button("Create"))
            InstantiatePrimitive();
    }

    void InstantiatePrimitive()
    {
        switch (index)
        {
            case 0:
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Vector3.zero;
                break;
            case 1:
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.position = Vector3.zero;
                break;
            case 2:
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.transform.position = Vector3.zero;
                break;
            default:
                Debug.LogError("Unrecognized Option");
                break;
        }
    }
}
```

## Popup(GUIContent, int, string\[], GUILayoutOption\[])

Make a generic popup selection field.

```csharp
public static int Popup(GUIContent label, int selectedIndex, string[] displayedOptions, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.7/script-reference/unityengine/guicontent)): Optional label in front of the field.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the option the field shows.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): An array with the options shown in the popup. Use a slash to separate sub-items (ex. Menu/SubMenu). Use null or an empty string to add a separator. "**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                       | Description                                                 |
| ---------------------------------------------------------- | ----------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the option that has been selected by the user. |

### Remarks

Takes the currently selected index as a parameter and returns the index selected by the user.

![EditorGUILayoutPopup (Popup)](/api/media?file=/engine/6000.7/media/images/EditorGUILayoutPopup.png)

*Create a primitive depending on the option selected.*

### Examples

```csharp
using UnityEditor;
using UnityEngine;
using System.Collections;

// Creates an instance of a primitive depending on the option selected by the user.
public class EditorGUILayoutPopup : EditorWindow
{
    public string[] options = new string[] {"Cube", "Sphere", "Plane"};
    public int index = 0;
    [MenuItem("Examples/Editor GUILayout Popup usage")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUILayoutPopup));
        window.Show();
    }

    void OnGUI()
    {
        index = EditorGUILayout.Popup(index, options);
        if (GUILayout.Button("Create"))
            InstantiatePrimitive();
    }

    void InstantiatePrimitive()
    {
        switch (index)
        {
            case 0:
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Vector3.zero;
                break;
            case 1:
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.position = Vector3.zero;
                break;
            case 2:
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.transform.position = Vector3.zero;
                break;
            default:
                Debug.LogError("Unrecognized Option");
                break;
        }
    }
}
```

## Popup(string, int, string\[], GUIStyle, GUILayoutOption\[])

Make a generic popup selection field.

```csharp
public static int Popup(string label, int selectedIndex, string[] displayedOptions, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Optional label in front of the field.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the option the field shows.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): An array with the options shown in the popup. Use a slash to separate sub-items (ex. Menu/SubMenu). Use null or an empty string to add a separator. "**** (\[GUIStyle]\(/engine/6000.7/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.7/script-reference/unityengine/guistyle.md).**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                       | Description                                                 |
| ---------------------------------------------------------- | ----------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the option that has been selected by the user. |

### Remarks

Takes the currently selected index as a parameter and returns the index selected by the user.

![EditorGUILayoutPopup (Popup)](/api/media?file=/engine/6000.7/media/images/EditorGUILayoutPopup.png)

*Create a primitive depending on the option selected.*

### Examples

```csharp
using UnityEditor;
using UnityEngine;
using System.Collections;

// Creates an instance of a primitive depending on the option selected by the user.
public class EditorGUILayoutPopup : EditorWindow
{
    public string[] options = new string[] {"Cube", "Sphere", "Plane"};
    public int index = 0;
    [MenuItem("Examples/Editor GUILayout Popup usage")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUILayoutPopup));
        window.Show();
    }

    void OnGUI()
    {
        index = EditorGUILayout.Popup(index, options);
        if (GUILayout.Button("Create"))
            InstantiatePrimitive();
    }

    void InstantiatePrimitive()
    {
        switch (index)
        {
            case 0:
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Vector3.zero;
                break;
            case 1:
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.position = Vector3.zero;
                break;
            case 2:
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.transform.position = Vector3.zero;
                break;
            default:
                Debug.LogError("Unrecognized Option");
                break;
        }
    }
}
```

## Popup(GUIContent, int, GUIContent\[], GUILayoutOption\[])

Make a generic popup selection field.

```csharp
public static int Popup(GUIContent label, int selectedIndex, GUIContent[] displayedOptions, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.7/script-reference/unityengine/guicontent)): Optional label in front of the field.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the option the field shows.**** (\[GUIContent\[]]\(/engine/6000.7/script-reference/unityengine/guicontent)): An array with the options shown in the popup. Use a slash to separate sub-items (ex. Menu/SubMenu). Use null or an empty string to add a separator. "**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                       | Description                                                 |
| ---------------------------------------------------------- | ----------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the option that has been selected by the user. |

### Remarks

Takes the currently selected index as a parameter and returns the index selected by the user.

![EditorGUILayoutPopup (Popup)](/api/media?file=/engine/6000.7/media/images/EditorGUILayoutPopup.png)

*Create a primitive depending on the option selected.*

### Examples

```csharp
using UnityEditor;
using UnityEngine;
using System.Collections;

// Creates an instance of a primitive depending on the option selected by the user.
public class EditorGUILayoutPopup : EditorWindow
{
    public string[] options = new string[] {"Cube", "Sphere", "Plane"};
    public int index = 0;
    [MenuItem("Examples/Editor GUILayout Popup usage")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUILayoutPopup));
        window.Show();
    }

    void OnGUI()
    {
        index = EditorGUILayout.Popup(index, options);
        if (GUILayout.Button("Create"))
            InstantiatePrimitive();
    }

    void InstantiatePrimitive()
    {
        switch (index)
        {
            case 0:
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Vector3.zero;
                break;
            case 1:
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.position = Vector3.zero;
                break;
            case 2:
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.transform.position = Vector3.zero;
                break;
            default:
                Debug.LogError("Unrecognized Option");
                break;
        }
    }
}
```

## Popup(GUIContent, int, GUIContent\[], GUIStyle, GUILayoutOption\[])

Make a generic popup selection field.

```csharp
public static int Popup(GUIContent label, int selectedIndex, GUIContent[] displayedOptions, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.7/script-reference/unityengine/guicontent)): Optional label in front of the field.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the option the field shows.**** (\[GUIContent\[]]\(/engine/6000.7/script-reference/unityengine/guicontent)): An array with the options shown in the popup. Use a slash to separate sub-items (ex. Menu/SubMenu). Use null or an empty string to add a separator. "**** (\[GUIStyle]\(/engine/6000.7/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.7/script-reference/unityengine/guistyle.md).**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layout properties. Any values passed in here will override settings defined by the `style`.\
&#x20;Additional Resources: [GUILayout.Width](/engine/6000.7/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.7/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.7/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.7/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.7/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.7/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.7/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.7/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                       | Description                                                 |
| ---------------------------------------------------------- | ----------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the option that has been selected by the user. |

### Remarks

Takes the currently selected index as a parameter and returns the index selected by the user.

![EditorGUILayoutPopup (Popup)](/api/media?file=/engine/6000.7/media/images/EditorGUILayoutPopup.png)

*Create a primitive depending on the option selected.*

### Examples

```csharp
using UnityEditor;
using UnityEngine;
using System.Collections;

// Creates an instance of a primitive depending on the option selected by the user.
public class EditorGUILayoutPopup : EditorWindow
{
    public string[] options = new string[] {"Cube", "Sphere", "Plane"};
    public int index = 0;
    [MenuItem("Examples/Editor GUILayout Popup usage")]
    static void Init()
    {
        EditorWindow window = GetWindow(typeof(EditorGUILayoutPopup));
        window.Show();
    }

    void OnGUI()
    {
        index = EditorGUILayout.Popup(index, options);
        if (GUILayout.Button("Create"))
            InstantiatePrimitive();
    }

    void InstantiatePrimitive()
    {
        switch (index)
        {
            case 0:
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Vector3.zero;
                break;
            case 1:
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.position = Vector3.zero;
                break;
            case 2:
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.transform.position = Vector3.zero;
                break;
            default:
                Debug.LogError("Unrecognized Option");
                break;
        }
    }
}
```
