# EnumPopup

> Make an enum popup selection field.

## Definition

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

## EnumPopup(Enum, GUILayoutOption\[])

Make an enum popup selection field.

```csharp
public static Enum EnumPopup(Enum selected, params GUILayoutOption[] options)
```

### Parameters

**** (\[Enum]\(https\://learn.microsoft.com/dotnet/api/system.enum)): The enum option the field shows.**** (\[GUILayoutOption\[]]\(/engine/6000.0/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.0/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.0/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.0/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.0/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.0/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.0/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.0/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.0/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

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

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

*Creates a primitive selected by the user.*

### Examples

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

// Creates an instance of a primitive depending on the option selected by the user.

public enum OPTIONS
{
    CUBE = 0,
    SPHERE = 1,
    PLANE = 2
}

public class EditorGUILayoutEnumPopup : EditorWindow
{
    public OPTIONS op;
    [MenuItem("Examples/Editor GUILayout Enum Popup usage")]
    static void Init()
    {
        UnityEditor.EditorWindow window = GetWindow(typeof(EditorGUILayoutEnumPopup));
        window.Show();
    }

    void OnGUI()
    {
        op = (OPTIONS)EditorGUILayout.EnumPopup("Primitive to create:", op);
        if (GUILayout.Button("Create"))
            InstantiatePrimitive(op);
    }

    void InstantiatePrimitive(OPTIONS op)
    {
        switch (op)
        {
            case OPTIONS.CUBE:
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Vector3.zero;
                break;
            case OPTIONS.SPHERE:
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.position = Vector3.zero;
                break;
            case OPTIONS.PLANE:
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.transform.position = Vector3.zero;
                break;
            default:
                Debug.LogError("Unrecognized Option");
                break;
        }
    }
}
```

## EnumPopup(Enum, GUIStyle, GUILayoutOption\[])

Make an enum popup selection field.

```csharp
public static Enum EnumPopup(Enum selected, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[Enum]\(https\://learn.microsoft.com/dotnet/api/system.enum)): The enum option the field shows.**** (\[GUIStyle]\(/engine/6000.0/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.0/script-reference/unityengine/guistyle.md).**** (\[GUILayoutOption\[]]\(/engine/6000.0/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.0/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.0/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.0/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.0/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.0/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.0/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.0/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.0/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

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

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

*Creates a primitive selected by the user.*

### Examples

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

// Creates an instance of a primitive depending on the option selected by the user.

public enum OPTIONS
{
    CUBE = 0,
    SPHERE = 1,
    PLANE = 2
}

public class EditorGUILayoutEnumPopup : EditorWindow
{
    public OPTIONS op;
    [MenuItem("Examples/Editor GUILayout Enum Popup usage")]
    static void Init()
    {
        UnityEditor.EditorWindow window = GetWindow(typeof(EditorGUILayoutEnumPopup));
        window.Show();
    }

    void OnGUI()
    {
        op = (OPTIONS)EditorGUILayout.EnumPopup("Primitive to create:", op);
        if (GUILayout.Button("Create"))
            InstantiatePrimitive(op);
    }

    void InstantiatePrimitive(OPTIONS op)
    {
        switch (op)
        {
            case OPTIONS.CUBE:
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Vector3.zero;
                break;
            case OPTIONS.SPHERE:
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.position = Vector3.zero;
                break;
            case OPTIONS.PLANE:
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.transform.position = Vector3.zero;
                break;
            default:
                Debug.LogError("Unrecognized Option");
                break;
        }
    }
}
```

## EnumPopup(string, Enum, GUILayoutOption\[])

Make an enum popup selection field.

```csharp
public static Enum EnumPopup(string label, Enum selected, params GUILayoutOption[] options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Optional label in front of the field.**** (\[Enum]\(https\://learn.microsoft.com/dotnet/api/system.enum)): The enum option the field shows.**** (\[GUILayoutOption\[]]\(/engine/6000.0/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.0/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.0/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.0/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.0/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.0/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.0/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.0/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.0/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

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

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

*Creates a primitive selected by the user.*

### Examples

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

// Creates an instance of a primitive depending on the option selected by the user.

public enum OPTIONS
{
    CUBE = 0,
    SPHERE = 1,
    PLANE = 2
}

public class EditorGUILayoutEnumPopup : EditorWindow
{
    public OPTIONS op;
    [MenuItem("Examples/Editor GUILayout Enum Popup usage")]
    static void Init()
    {
        UnityEditor.EditorWindow window = GetWindow(typeof(EditorGUILayoutEnumPopup));
        window.Show();
    }

    void OnGUI()
    {
        op = (OPTIONS)EditorGUILayout.EnumPopup("Primitive to create:", op);
        if (GUILayout.Button("Create"))
            InstantiatePrimitive(op);
    }

    void InstantiatePrimitive(OPTIONS op)
    {
        switch (op)
        {
            case OPTIONS.CUBE:
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Vector3.zero;
                break;
            case OPTIONS.SPHERE:
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.position = Vector3.zero;
                break;
            case OPTIONS.PLANE:
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.transform.position = Vector3.zero;
                break;
            default:
                Debug.LogError("Unrecognized Option");
                break;
        }
    }
}
```

## EnumPopup(string, Enum, GUIStyle, GUILayoutOption\[])

Make an enum popup selection field.

```csharp
public static Enum EnumPopup(string label, Enum selected, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Optional label in front of the field.**** (\[Enum]\(https\://learn.microsoft.com/dotnet/api/system.enum)): The enum option the field shows.**** (\[GUIStyle]\(/engine/6000.0/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.0/script-reference/unityengine/guistyle.md).**** (\[GUILayoutOption\[]]\(/engine/6000.0/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.0/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.0/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.0/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.0/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.0/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.0/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.0/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.0/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

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

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

*Creates a primitive selected by the user.*

### Examples

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

// Creates an instance of a primitive depending on the option selected by the user.

public enum OPTIONS
{
    CUBE = 0,
    SPHERE = 1,
    PLANE = 2
}

public class EditorGUILayoutEnumPopup : EditorWindow
{
    public OPTIONS op;
    [MenuItem("Examples/Editor GUILayout Enum Popup usage")]
    static void Init()
    {
        UnityEditor.EditorWindow window = GetWindow(typeof(EditorGUILayoutEnumPopup));
        window.Show();
    }

    void OnGUI()
    {
        op = (OPTIONS)EditorGUILayout.EnumPopup("Primitive to create:", op);
        if (GUILayout.Button("Create"))
            InstantiatePrimitive(op);
    }

    void InstantiatePrimitive(OPTIONS op)
    {
        switch (op)
        {
            case OPTIONS.CUBE:
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Vector3.zero;
                break;
            case OPTIONS.SPHERE:
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.position = Vector3.zero;
                break;
            case OPTIONS.PLANE:
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.transform.position = Vector3.zero;
                break;
            default:
                Debug.LogError("Unrecognized Option");
                break;
        }
    }
}
```

## EnumPopup(GUIContent, Enum, GUILayoutOption\[])

Make an enum popup selection field.

```csharp
public static Enum EnumPopup(GUIContent label, Enum selected, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.0/script-reference/unityengine/guicontent)): Optional label in front of the field.**** (\[Enum]\(https\://learn.microsoft.com/dotnet/api/system.enum)): The enum option the field shows.**** (\[GUILayoutOption\[]]\(/engine/6000.0/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.0/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.0/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.0/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.0/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.0/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.0/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.0/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.0/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

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

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

*Creates a primitive selected by the user.*

### Examples

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

// Creates an instance of a primitive depending on the option selected by the user.

public enum OPTIONS
{
    CUBE = 0,
    SPHERE = 1,
    PLANE = 2
}

public class EditorGUILayoutEnumPopup : EditorWindow
{
    public OPTIONS op;
    [MenuItem("Examples/Editor GUILayout Enum Popup usage")]
    static void Init()
    {
        UnityEditor.EditorWindow window = GetWindow(typeof(EditorGUILayoutEnumPopup));
        window.Show();
    }

    void OnGUI()
    {
        op = (OPTIONS)EditorGUILayout.EnumPopup("Primitive to create:", op);
        if (GUILayout.Button("Create"))
            InstantiatePrimitive(op);
    }

    void InstantiatePrimitive(OPTIONS op)
    {
        switch (op)
        {
            case OPTIONS.CUBE:
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Vector3.zero;
                break;
            case OPTIONS.SPHERE:
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.position = Vector3.zero;
                break;
            case OPTIONS.PLANE:
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.transform.position = Vector3.zero;
                break;
            default:
                Debug.LogError("Unrecognized Option");
                break;
        }
    }
}
```

## EnumPopup(GUIContent, Enum, GUIStyle, GUILayoutOption\[])

Make an enum popup selection field.

```csharp
public static Enum EnumPopup(GUIContent label, Enum selected, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.0/script-reference/unityengine/guicontent)): Optional label in front of the field.**** (\[Enum]\(https\://learn.microsoft.com/dotnet/api/system.enum)): The enum option the field shows.**** (\[GUIStyle]\(/engine/6000.0/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.0/script-reference/unityengine/guistyle.md).**** (\[GUILayoutOption\[]]\(/engine/6000.0/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.0/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.0/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.0/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.0/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.0/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.0/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.0/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.0/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

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

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

*Creates a primitive selected by the user.*

### Examples

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

// Creates an instance of a primitive depending on the option selected by the user.

public enum OPTIONS
{
    CUBE = 0,
    SPHERE = 1,
    PLANE = 2
}

public class EditorGUILayoutEnumPopup : EditorWindow
{
    public OPTIONS op;
    [MenuItem("Examples/Editor GUILayout Enum Popup usage")]
    static void Init()
    {
        UnityEditor.EditorWindow window = GetWindow(typeof(EditorGUILayoutEnumPopup));
        window.Show();
    }

    void OnGUI()
    {
        op = (OPTIONS)EditorGUILayout.EnumPopup("Primitive to create:", op);
        if (GUILayout.Button("Create"))
            InstantiatePrimitive(op);
    }

    void InstantiatePrimitive(OPTIONS op)
    {
        switch (op)
        {
            case OPTIONS.CUBE:
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Vector3.zero;
                break;
            case OPTIONS.SPHERE:
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.position = Vector3.zero;
                break;
            case OPTIONS.PLANE:
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.transform.position = Vector3.zero;
                break;
            default:
                Debug.LogError("Unrecognized Option");
                break;
        }
    }
}
```

## EnumPopup(GUIContent, Enum, Func\<Enum, bool>, bool, GUILayoutOption\[])

Make an enum popup selection field.

```csharp
public static Enum EnumPopup(GUIContent label, Enum selected, Func<Enum, bool> checkEnabled, bool includeObsolete, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.0/script-reference/unityengine/guicontent)): Optional label in front of the field.**** (\[Enum]\(https\://learn.microsoft.com/dotnet/api/system.enum)): The enum option the field shows.**** (\[Func\<Enum, bool>]\(https\://learn.microsoft.com/dotnet/api/system.func-1)): Method called for each Enum value displayed. The specified method should return true if the option can be selected, false otherwise.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Set to true to include Enum values with ObsoleteAttribute. Set to false to exclude Enum values with ObsoleteAttribute.**** (\[GUILayoutOption\[]]\(/engine/6000.0/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.0/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.0/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.0/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.0/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.0/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.0/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.0/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.0/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

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

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

*Creates a primitive selected by the user.*

### Examples

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

// Creates an instance of a primitive depending on the option selected by the user.

public enum OPTIONS
{
    CUBE = 0,
    SPHERE = 1,
    PLANE = 2
}

public class EditorGUILayoutEnumPopup : EditorWindow
{
    public OPTIONS op;
    [MenuItem("Examples/Editor GUILayout Enum Popup usage")]
    static void Init()
    {
        UnityEditor.EditorWindow window = GetWindow(typeof(EditorGUILayoutEnumPopup));
        window.Show();
    }

    void OnGUI()
    {
        op = (OPTIONS)EditorGUILayout.EnumPopup("Primitive to create:", op);
        if (GUILayout.Button("Create"))
            InstantiatePrimitive(op);
    }

    void InstantiatePrimitive(OPTIONS op)
    {
        switch (op)
        {
            case OPTIONS.CUBE:
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Vector3.zero;
                break;
            case OPTIONS.SPHERE:
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.position = Vector3.zero;
                break;
            case OPTIONS.PLANE:
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.transform.position = Vector3.zero;
                break;
            default:
                Debug.LogError("Unrecognized Option");
                break;
        }
    }
}
```

## EnumPopup(GUIContent, Enum, Func\<Enum, bool>, bool, GUIStyle, GUILayoutOption\[])

Make an enum popup selection field.

```csharp
public static Enum EnumPopup(GUIContent label, Enum selected, Func<Enum, bool> checkEnabled, bool includeObsolete, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.0/script-reference/unityengine/guicontent)): Optional label in front of the field.**** (\[Enum]\(https\://learn.microsoft.com/dotnet/api/system.enum)): The enum option the field shows.**** (\[Func\<Enum, bool>]\(https\://learn.microsoft.com/dotnet/api/system.func-1)): Method called for each Enum value displayed. The specified method should return true if the option can be selected, false otherwise.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Set to true to include Enum values with ObsoleteAttribute. Set to false to exclude Enum values with ObsoleteAttribute.**** (\[GUIStyle]\(/engine/6000.0/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.0/script-reference/unityengine/guistyle.md).**** (\[GUILayoutOption\[]]\(/engine/6000.0/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.0/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.0/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.0/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.0/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.0/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.0/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.0/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.0/script-reference/unityengine/guilayout/expandheight.md).

### Returns

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

### Remarks

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

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

*Creates a primitive selected by the user.*

### Examples

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

// Creates an instance of a primitive depending on the option selected by the user.

public enum OPTIONS
{
    CUBE = 0,
    SPHERE = 1,
    PLANE = 2
}

public class EditorGUILayoutEnumPopup : EditorWindow
{
    public OPTIONS op;
    [MenuItem("Examples/Editor GUILayout Enum Popup usage")]
    static void Init()
    {
        UnityEditor.EditorWindow window = GetWindow(typeof(EditorGUILayoutEnumPopup));
        window.Show();
    }

    void OnGUI()
    {
        op = (OPTIONS)EditorGUILayout.EnumPopup("Primitive to create:", op);
        if (GUILayout.Button("Create"))
            InstantiatePrimitive(op);
    }

    void InstantiatePrimitive(OPTIONS op)
    {
        switch (op)
        {
            case OPTIONS.CUBE:
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Vector3.zero;
                break;
            case OPTIONS.SPHERE:
                GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                sphere.transform.position = Vector3.zero;
                break;
            case OPTIONS.PLANE:
                GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
                plane.transform.position = Vector3.zero;
                break;
            default:
                Debug.LogError("Unrecognized Option");
                break;
        }
    }
}
```
