# Toggle

> Make a toggle.

## Definition

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

## Toggle(bool, GUILayoutOption\[])

Make a toggle.

```csharp
public static bool Toggle(bool value, params GUILayoutOption[] options)
```

### Parameters

**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): The shown state of the toggle.**** (\[GUILayoutOption\[]]\(/engine/6000.6/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`.\Additional Resources: [GUILayout.Width](/engine/6000.6/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.6/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.6/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.6/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.6/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.6/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.6/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.6/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                          | Description                       |
| ------------------------------------------------------------- | --------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | The selected state of the toggle. |

### Remarks

![EditorGUILayoutToggle (Toggle)](/api/media?file=/engine/6000.6/media/images/EditorGUILayoutToggle.png)

*Show a button if the toggle control is selected.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;

public class EditorGUILayoutToggle : UnityEditor.EditorWindow
{
    bool showBtn = true;

    [MenuItem("Examples/Editor GUILayout Toggle Usage")]
    static void Init()
    {
        EditorGUILayoutToggle window = (EditorGUILayoutToggle)EditorWindow.GetWindow(typeof(EditorGUILayoutToggle), true, "My Empty Window");
        window.Show();
    }

    void OnGUI()
    {
        showBtn = EditorGUILayout.Toggle("Show Button", showBtn);
        if (showBtn)
            if (GUILayout.Button("Close"))
                this.Close();
    }
}
```

## Toggle(string, bool, GUILayoutOption\[])

Make a toggle.

```csharp
public static bool Toggle(string label, bool value, params GUILayoutOption[] options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Optional label in front of the toggle.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): The shown state of the toggle.**** (\[GUILayoutOption\[]]\(/engine/6000.6/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`.\Additional Resources: [GUILayout.Width](/engine/6000.6/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.6/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.6/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.6/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.6/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.6/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.6/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.6/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                          | Description                       |
| ------------------------------------------------------------- | --------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | The selected state of the toggle. |

### Remarks

![EditorGUILayoutToggle (Toggle)](/api/media?file=/engine/6000.6/media/images/EditorGUILayoutToggle.png)

*Show a button if the toggle control is selected.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;

public class EditorGUILayoutToggle : UnityEditor.EditorWindow
{
    bool showBtn = true;

    [MenuItem("Examples/Editor GUILayout Toggle Usage")]
    static void Init()
    {
        EditorGUILayoutToggle window = (EditorGUILayoutToggle)EditorWindow.GetWindow(typeof(EditorGUILayoutToggle), true, "My Empty Window");
        window.Show();
    }

    void OnGUI()
    {
        showBtn = EditorGUILayout.Toggle("Show Button", showBtn);
        if (showBtn)
            if (GUILayout.Button("Close"))
                this.Close();
    }
}
```

## Toggle(GUIContent, bool, GUILayoutOption\[])

Make a toggle.

```csharp
public static bool Toggle(GUIContent label, bool value, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.6/script-reference/unityengine/guicontent)): Optional label in front of the toggle.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): The shown state of the toggle.**** (\[GUILayoutOption\[]]\(/engine/6000.6/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`.\Additional Resources: [GUILayout.Width](/engine/6000.6/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.6/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.6/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.6/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.6/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.6/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.6/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.6/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                          | Description                       |
| ------------------------------------------------------------- | --------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | The selected state of the toggle. |

### Remarks

![EditorGUILayoutToggle (Toggle)](/api/media?file=/engine/6000.6/media/images/EditorGUILayoutToggle.png)

*Show a button if the toggle control is selected.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;

public class EditorGUILayoutToggle : UnityEditor.EditorWindow
{
    bool showBtn = true;

    [MenuItem("Examples/Editor GUILayout Toggle Usage")]
    static void Init()
    {
        EditorGUILayoutToggle window = (EditorGUILayoutToggle)EditorWindow.GetWindow(typeof(EditorGUILayoutToggle), true, "My Empty Window");
        window.Show();
    }

    void OnGUI()
    {
        showBtn = EditorGUILayout.Toggle("Show Button", showBtn);
        if (showBtn)
            if (GUILayout.Button("Close"))
                this.Close();
    }
}
```

## Toggle(bool, GUIStyle, GUILayoutOption\[])

Make a toggle.

```csharp
public static bool Toggle(bool value, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): The shown state of the toggle.**** (\[GUIStyle]\(/engine/6000.6/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.6/script-reference/unityengine/guistyle.md).**** (\[GUILayoutOption\[]]\(/engine/6000.6/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`.\Additional Resources: [GUILayout.Width](/engine/6000.6/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.6/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.6/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.6/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.6/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.6/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.6/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.6/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                          | Description                       |
| ------------------------------------------------------------- | --------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | The selected state of the toggle. |

### Remarks

![EditorGUILayoutToggle (Toggle)](/api/media?file=/engine/6000.6/media/images/EditorGUILayoutToggle.png)

*Show a button if the toggle control is selected.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;

public class EditorGUILayoutToggle : UnityEditor.EditorWindow
{
    bool showBtn = true;

    [MenuItem("Examples/Editor GUILayout Toggle Usage")]
    static void Init()
    {
        EditorGUILayoutToggle window = (EditorGUILayoutToggle)EditorWindow.GetWindow(typeof(EditorGUILayoutToggle), true, "My Empty Window");
        window.Show();
    }

    void OnGUI()
    {
        showBtn = EditorGUILayout.Toggle("Show Button", showBtn);
        if (showBtn)
            if (GUILayout.Button("Close"))
                this.Close();
    }
}
```

## Toggle(string, bool, GUIStyle, GUILayoutOption\[])

Make a toggle.

```csharp
public static bool Toggle(string label, bool value, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Optional label in front of the toggle.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): The shown state of the toggle.**** (\[GUIStyle]\(/engine/6000.6/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.6/script-reference/unityengine/guistyle.md).**** (\[GUILayoutOption\[]]\(/engine/6000.6/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`.\Additional Resources: [GUILayout.Width](/engine/6000.6/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.6/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.6/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.6/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.6/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.6/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.6/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.6/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                          | Description                       |
| ------------------------------------------------------------- | --------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | The selected state of the toggle. |

### Remarks

![EditorGUILayoutToggle (Toggle)](/api/media?file=/engine/6000.6/media/images/EditorGUILayoutToggle.png)

*Show a button if the toggle control is selected.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;

public class EditorGUILayoutToggle : UnityEditor.EditorWindow
{
    bool showBtn = true;

    [MenuItem("Examples/Editor GUILayout Toggle Usage")]
    static void Init()
    {
        EditorGUILayoutToggle window = (EditorGUILayoutToggle)EditorWindow.GetWindow(typeof(EditorGUILayoutToggle), true, "My Empty Window");
        window.Show();
    }

    void OnGUI()
    {
        showBtn = EditorGUILayout.Toggle("Show Button", showBtn);
        if (showBtn)
            if (GUILayout.Button("Close"))
                this.Close();
    }
}
```

## Toggle(GUIContent, bool, GUIStyle, GUILayoutOption\[])

Make a toggle.

```csharp
public static bool Toggle(GUIContent label, bool value, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.6/script-reference/unityengine/guicontent)): Optional label in front of the toggle.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): The shown state of the toggle.**** (\[GUIStyle]\(/engine/6000.6/script-reference/unityengine/guistyle)): Optional [GUIStyle](/engine/6000.6/script-reference/unityengine/guistyle.md).**** (\[GUILayoutOption\[]]\(/engine/6000.6/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`.\Additional Resources: [GUILayout.Width](/engine/6000.6/script-reference/unityengine/guilayout/width.md), [GUILayout.Height](/engine/6000.6/script-reference/unityengine/guilayout/height.md), [GUILayout.MinWidth](/engine/6000.6/script-reference/unityengine/guilayout/minwidth.md), [GUILayout.MaxWidth](/engine/6000.6/script-reference/unityengine/guilayout/maxwidth.md), [GUILayout.MinHeight](/engine/6000.6/script-reference/unityengine/guilayout/minheight.md), [GUILayout.MaxHeight](/engine/6000.6/script-reference/unityengine/guilayout/maxheight.md), [GUILayout.ExpandWidth](/engine/6000.6/script-reference/unityengine/guilayout/expandwidth.md), [GUILayout.ExpandHeight](/engine/6000.6/script-reference/unityengine/guilayout/expandheight.md).

### Returns

| Type                                                          | Description                       |
| ------------------------------------------------------------- | --------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | The selected state of the toggle. |

### Remarks

![EditorGUILayoutToggle (Toggle)](/api/media?file=/engine/6000.6/media/images/EditorGUILayoutToggle.png)

*Show a button if the toggle control is selected.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;

public class EditorGUILayoutToggle : UnityEditor.EditorWindow
{
    bool showBtn = true;

    [MenuItem("Examples/Editor GUILayout Toggle Usage")]
    static void Init()
    {
        EditorGUILayoutToggle window = (EditorGUILayoutToggle)EditorWindow.GetWindow(typeof(EditorGUILayoutToggle), true, "My Empty Window");
        window.Show();
    }

    void OnGUI()
    {
        showBtn = EditorGUILayout.Toggle("Show Button", showBtn);
        if (showBtn)
            if (GUILayout.Button("Close"))
                this.Close();
    }
}
```
