# SelectionGrid

> Make a Selection Grid.

## Definition

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

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

Make a Selection Grid.

```csharp
public static int SelectionGrid(int selected, string[] texts, int xCount, params GUILayoutOption[] options)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the selected button.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): An array of strings to show on the buttons.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): How many elements to fit in the horizontal direction. The elements will be scaled to fit unless the style defines a fixedWidth to use. The height of the control will be determined from the number of elements.**** (\[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                       |
| ---------------------------------------------------------- | --------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the selected button. |

### Remarks

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

Selection grid 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
{
    int selGridInt = 0;
    string[] selStrings = {"radio1", "radio2", "radio3"};

    void OnGUI()
    {
        GUILayout.BeginVertical("Box");
        selGridInt = GUILayout.SelectionGrid(selGridInt, selStrings, 1);
        if (GUILayout.Button("Start"))
        {
            Debug.Log("You chose " + selStrings[selGridInt]);
        }
        GUILayout.EndVertical();
    }
}
```

## SelectionGrid(int, Texture\[], int, GUILayoutOption\[])

Make a Selection Grid.

```csharp
public static int SelectionGrid(int selected, Texture[] images, int xCount, params GUILayoutOption[] options)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the selected button.**** (\[Texture\[]]\(/engine/6000.7/script-reference/unityengine/texture)): An array of textures on the buttons.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): How many elements to fit in the horizontal direction. The elements will be scaled to fit unless the style defines a fixedWidth to use. The height of the control will be determined from the number of elements.**** (\[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                       |
| ---------------------------------------------------------- | --------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the selected button. |

### Remarks

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

Selection grid 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
{
    int selGridInt = 0;
    string[] selStrings = {"radio1", "radio2", "radio3"};

    void OnGUI()
    {
        GUILayout.BeginVertical("Box");
        selGridInt = GUILayout.SelectionGrid(selGridInt, selStrings, 1);
        if (GUILayout.Button("Start"))
        {
            Debug.Log("You chose " + selStrings[selGridInt]);
        }
        GUILayout.EndVertical();
    }
}
```

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

Make a Selection Grid.

```csharp
public static int SelectionGrid(int selected, GUIContent[] content, int xCount, params GUILayoutOption[] options)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the selected button.**** (\[GUIContent\[]]\(/engine/6000.7/script-reference/unityengine/guicontent)): **** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): How many elements to fit in the horizontal direction. The elements will be scaled to fit unless the style defines a fixedWidth to use. The height of the control will be determined from the number of elements.**** (\[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                       |
| ---------------------------------------------------------- | --------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the selected button. |

### Remarks

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

Selection grid 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
{
    int selGridInt = 0;
    string[] selStrings = {"radio1", "radio2", "radio3"};

    void OnGUI()
    {
        GUILayout.BeginVertical("Box");
        selGridInt = GUILayout.SelectionGrid(selGridInt, selStrings, 1);
        if (GUILayout.Button("Start"))
        {
            Debug.Log("You chose " + selStrings[selGridInt]);
        }
        GUILayout.EndVertical();
    }
}
```

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

Make a Selection Grid.

```csharp
public static int SelectionGrid(int selected, string[] texts, int xCount, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the selected button.**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): An array of strings to show on the buttons.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): How many elements to fit in the horizontal direction. The elements will be scaled to fit unless the style defines a fixedWidth to use. The height of the control will be determined from the number of elements.**** (\[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                       |
| ---------------------------------------------------------- | --------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the selected button. |

### Remarks

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

Selection grid 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
{
    int selGridInt = 0;
    string[] selStrings = {"radio1", "radio2", "radio3"};

    void OnGUI()
    {
        GUILayout.BeginVertical("Box");
        selGridInt = GUILayout.SelectionGrid(selGridInt, selStrings, 1);
        if (GUILayout.Button("Start"))
        {
            Debug.Log("You chose " + selStrings[selGridInt]);
        }
        GUILayout.EndVertical();
    }
}
```

## SelectionGrid(int, Texture\[], int, GUIStyle, GUILayoutOption\[])

Make a Selection Grid.

```csharp
public static int SelectionGrid(int selected, Texture[] images, int xCount, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the selected button.**** (\[Texture\[]]\(/engine/6000.7/script-reference/unityengine/texture)): An array of textures on the buttons.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): How many elements to fit in the horizontal direction. The elements will be scaled to fit unless the style defines a fixedWidth to use. The height of the control will be determined from the number of elements.**** (\[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                       |
| ---------------------------------------------------------- | --------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the selected button. |

### Remarks

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

Selection grid 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
{
    int selGridInt = 0;
    string[] selStrings = {"radio1", "radio2", "radio3"};

    void OnGUI()
    {
        GUILayout.BeginVertical("Box");
        selGridInt = GUILayout.SelectionGrid(selGridInt, selStrings, 1);
        if (GUILayout.Button("Start"))
        {
            Debug.Log("You chose " + selStrings[selGridInt]);
        }
        GUILayout.EndVertical();
    }
}
```

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

Make a Selection Grid.

```csharp
public static int SelectionGrid(int selected, GUIContent[] contents, int xCount, GUIStyle style, params GUILayoutOption[] options)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the selected button.**** (\[GUIContent\[]]\(/engine/6000.7/script-reference/unityengine/guicontent)): An array of text, image and tooltips for the button.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): How many elements to fit in the horizontal direction. The elements will be scaled to fit unless the style defines a fixedWidth to use. The height of the control will be determined from the number of elements.**** (\[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                       |
| ---------------------------------------------------------- | --------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the selected button. |

### Remarks

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

Selection grid 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
{
    int selGridInt = 0;
    string[] selStrings = {"radio1", "radio2", "radio3"};

    void OnGUI()
    {
        GUILayout.BeginVertical("Box");
        selGridInt = GUILayout.SelectionGrid(selGridInt, selStrings, 1);
        if (GUILayout.Button("Start"))
        {
            Debug.Log("You chose " + selStrings[selGridInt]);
        }
        GUILayout.EndVertical();
    }
}
```
