# Button

> Make a single press button.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.IMGUIModule

## Button(Texture, GUILayoutOption\[])

Make a single press button.

```csharp
public static bool Button(Texture image, params GUILayoutOption[] options)
```

### Parameters

**** (\[Texture]\(/engine/6000.7/script-reference/unityengine/texture)): [Texture](/engine/6000.7/script-reference/unityengine/texture.md) to display on the button.**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the `style`.\
&#x20;[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                            |
| ------------------------------------------------------------- | -------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | true when the users clicks the button. |

### Remarks

Create a [GUILayout.Button](/engine/6000.7/script-reference/unityengine/guilayout/button.md) that can be pressed and released as a normal button.  When this [GUILayout.Button](/engine/6000.7/script-reference/unityengine/guilayout/button.md) is released the Button returns the expected `true` value. If the mouse is moved off the button it is not clicked.

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

Buttons in the Game View.

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)

### Examples

```csharp
using UnityEngine;

public class ExampleScript : MonoBehaviour
{
    // Draws a button with an image and a button with text
    Texture tex;

    void OnGUI()
    {
        if (!tex)
        {
            Debug.LogError("No texture found, please assign a texture on the inspector");
        }

        if (GUILayout.Button(tex))
        {
            Debug.Log("Clicked the image");
        }
        if (GUILayout.Button("I am a regular Automatic Layout Button"))
        {
            Debug.Log("Clicked Button");
        }
    }
}
```

## Button(string, GUILayoutOption\[])

Make a single press button.

```csharp
public static bool Button(string text, params GUILayoutOption[] options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Text to display on the button.**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the `style`.\
&#x20;[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                            |
| ------------------------------------------------------------- | -------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | true when the users clicks the button. |

### Remarks

Create a [GUILayout.Button](/engine/6000.7/script-reference/unityengine/guilayout/button.md) that can be pressed and released as a normal button.  When this [GUILayout.Button](/engine/6000.7/script-reference/unityengine/guilayout/button.md) is released the Button returns the expected `true` value. If the mouse is moved off the button it is not clicked.

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

Buttons in the Game View.

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)

### Examples

```csharp
using UnityEngine;

public class ExampleScript : MonoBehaviour
{
    // Draws a button with an image and a button with text
    Texture tex;

    void OnGUI()
    {
        if (!tex)
        {
            Debug.LogError("No texture found, please assign a texture on the inspector");
        }

        if (GUILayout.Button(tex))
        {
            Debug.Log("Clicked the image");
        }
        if (GUILayout.Button("I am a regular Automatic Layout Button"))
        {
            Debug.Log("Clicked Button");
        }
    }
}
```

## Button(GUIContent, GUILayoutOption\[])

Make a single press button.

```csharp
public static bool Button(GUIContent content, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.7/script-reference/unityengine/guicontent)): Text, image and tooltip for this button.**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the `style`.\
&#x20;[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                            |
| ------------------------------------------------------------- | -------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | true when the users clicks the button. |

### Remarks

Create a [GUILayout.Button](/engine/6000.7/script-reference/unityengine/guilayout/button.md) that can be pressed and released as a normal button.  When this [GUILayout.Button](/engine/6000.7/script-reference/unityengine/guilayout/button.md) is released the Button returns the expected `true` value. If the mouse is moved off the button it is not clicked.

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

Buttons in the Game View.

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)

### Examples

```csharp
using UnityEngine;

public class ExampleScript : MonoBehaviour
{
    // Draws a button with an image and a button with text
    Texture tex;

    void OnGUI()
    {
        if (!tex)
        {
            Debug.LogError("No texture found, please assign a texture on the inspector");
        }

        if (GUILayout.Button(tex))
        {
            Debug.Log("Clicked the image");
        }
        if (GUILayout.Button("I am a regular Automatic Layout Button"))
        {
            Debug.Log("Clicked Button");
        }
    }
}
```

## Button(Texture, GUIStyle, GUILayoutOption\[])

Make a single press button.

```csharp
public static bool Button(Texture image, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[Texture]\(/engine/6000.7/script-reference/unityengine/texture)): [Texture](/engine/6000.7/script-reference/unityengine/texture.md) to display on the button.**** (\[GUIStyle]\(/engine/6000.7/script-reference/unityengine/guistyle)): The style to use. If left out, the `button` style from the current [GUISkin](/engine/6000.7/script-reference/unityengine/guiskin.md) is used.**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the `style`.\
&#x20;[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                            |
| ------------------------------------------------------------- | -------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | true when the users clicks the button. |

### Remarks

Create a [GUILayout.Button](/engine/6000.7/script-reference/unityengine/guilayout/button.md) that can be pressed and released as a normal button.  When this [GUILayout.Button](/engine/6000.7/script-reference/unityengine/guilayout/button.md) is released the Button returns the expected `true` value. If the mouse is moved off the button it is not clicked.

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

Buttons in the Game View.

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)

### Examples

```csharp
using UnityEngine;

public class ExampleScript : MonoBehaviour
{
    // Draws a button with an image and a button with text
    Texture tex;

    void OnGUI()
    {
        if (!tex)
        {
            Debug.LogError("No texture found, please assign a texture on the inspector");
        }

        if (GUILayout.Button(tex))
        {
            Debug.Log("Clicked the image");
        }
        if (GUILayout.Button("I am a regular Automatic Layout Button"))
        {
            Debug.Log("Clicked Button");
        }
    }
}
```

## Button(string, GUIStyle, GUILayoutOption\[])

Make a single press button.

```csharp
public static bool Button(string text, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Text to display on the button.**** (\[GUIStyle]\(/engine/6000.7/script-reference/unityengine/guistyle)): The style to use. If left out, the `button` style from the current [GUISkin](/engine/6000.7/script-reference/unityengine/guiskin.md) is used.**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the `style`.\
&#x20;[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                            |
| ------------------------------------------------------------- | -------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | true when the users clicks the button. |

### Remarks

Create a [GUILayout.Button](/engine/6000.7/script-reference/unityengine/guilayout/button.md) that can be pressed and released as a normal button.  When this [GUILayout.Button](/engine/6000.7/script-reference/unityengine/guilayout/button.md) is released the Button returns the expected `true` value. If the mouse is moved off the button it is not clicked.

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

Buttons in the Game View.

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)

### Examples

```csharp
using UnityEngine;

public class ExampleScript : MonoBehaviour
{
    // Draws a button with an image and a button with text
    Texture tex;

    void OnGUI()
    {
        if (!tex)
        {
            Debug.LogError("No texture found, please assign a texture on the inspector");
        }

        if (GUILayout.Button(tex))
        {
            Debug.Log("Clicked the image");
        }
        if (GUILayout.Button("I am a regular Automatic Layout Button"))
        {
            Debug.Log("Clicked Button");
        }
    }
}
```

## Button(GUIContent, GUIStyle, GUILayoutOption\[])

Make a single press button.

```csharp
public static bool Button(GUIContent content, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[GUIContent]\(/engine/6000.7/script-reference/unityengine/guicontent)): Text, image and tooltip for this button.**** (\[GUIStyle]\(/engine/6000.7/script-reference/unityengine/guistyle)): The style to use. If left out, the `button` style from the current [GUISkin](/engine/6000.7/script-reference/unityengine/guiskin.md) is used.**** (\[GUILayoutOption\[]]\(/engine/6000.7/script-reference/unityengine/guilayoutoption)): An optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the `style`.\
&#x20;[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                            |
| ------------------------------------------------------------- | -------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | true when the users clicks the button. |

### Remarks

Create a [GUILayout.Button](/engine/6000.7/script-reference/unityengine/guilayout/button.md) that can be pressed and released as a normal button.  When this [GUILayout.Button](/engine/6000.7/script-reference/unityengine/guilayout/button.md) is released the Button returns the expected `true` value. If the mouse is moved off the button it is not clicked.

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

Buttons in the Game View.

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)

### Examples

```csharp
using UnityEngine;

public class ExampleScript : MonoBehaviour
{
    // Draws a button with an image and a button with text
    Texture tex;

    void OnGUI()
    {
        if (!tex)
        {
            Debug.LogError("No texture found, please assign a texture on the inspector");
        }

        if (GUILayout.Button(tex))
        {
            Debug.Log("Clicked the image");
        }
        if (GUILayout.Button("I am a regular Automatic Layout Button"))
        {
            Debug.Log("Clicked Button");
        }
    }
}
```
