# Toolbar

> Make a toolbar.

## Definition

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

## Toolbar(Rect, int, string\[])

Make a toolbar.

```csharp
public static int Toolbar(Rect position, int selected, string[] texts)
```

### Parameters

**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): Rectangle on the screen to use for the toolbar.**** (\[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 toolbar buttons.

### Returns

| Type                                                       | Description                       |
| ---------------------------------------------------------- | --------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the selected button. |

### Examples

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

public class ExampleClass : MonoBehaviour
{
    public int toolbarInt = 0;
    public string[] toolbarStrings = new string[] {"Toolbar1", "Toolbar2", "Toolbar3"};

    void OnGUI()
    {
        toolbarInt = GUI.Toolbar(new Rect(25, 25, 250, 30), toolbarInt, toolbarStrings);
    }
}
```

## Toolbar(Rect, int, Texture\[])

Make a toolbar.

```csharp
public static int Toolbar(Rect position, int selected, Texture[] images)
```

### Parameters

**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): Rectangle on the screen to use for the toolbar.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the selected button.**** (\[Texture\[]]\(/engine/6000.0/script-reference/unityengine/texture)): An array of textures on the toolbar buttons.

### Returns

| Type                                                       | Description                       |
| ---------------------------------------------------------- | --------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the selected button. |

### Examples

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

public class ExampleClass : MonoBehaviour
{
    public int toolbarInt = 0;
    public string[] toolbarStrings = new string[] {"Toolbar1", "Toolbar2", "Toolbar3"};

    void OnGUI()
    {
        toolbarInt = GUI.Toolbar(new Rect(25, 25, 250, 30), toolbarInt, toolbarStrings);
    }
}
```

## Toolbar(Rect, int, GUIContent\[])

Make a toolbar.

```csharp
public static int Toolbar(Rect position, int selected, GUIContent[] contents)
```

### Parameters

**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): Rectangle on the screen to use for the toolbar.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the selected button.**** (\[GUIContent\[]]\(/engine/6000.0/script-reference/unityengine/guicontent)): An array of text, image and tooltips for the toolbar buttons.

### Returns

| Type                                                       | Description                       |
| ---------------------------------------------------------- | --------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the selected button. |

### Examples

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

public class ExampleClass : MonoBehaviour
{
    public int toolbarInt = 0;
    public string[] toolbarStrings = new string[] {"Toolbar1", "Toolbar2", "Toolbar3"};

    void OnGUI()
    {
        toolbarInt = GUI.Toolbar(new Rect(25, 25, 250, 30), toolbarInt, toolbarStrings);
    }
}
```

## Toolbar(Rect, int, string\[], GUIStyle)

Make a toolbar.

```csharp
public static int Toolbar(Rect position, int selected, string[] texts, GUIStyle style)
```

### Parameters

**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): Rectangle on the screen to use for the toolbar.**** (\[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 toolbar buttons.**** (\[GUIStyle]\(/engine/6000.0/script-reference/unityengine/guistyle)): The style to use. If left out, the button style from the current [GUISkin](/engine/6000.0/script-reference/unityengine/guiskin.md) is used.

### Returns

| Type                                                       | Description                       |
| ---------------------------------------------------------- | --------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the selected button. |

### Examples

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

public class ExampleClass : MonoBehaviour
{
    public int toolbarInt = 0;
    public string[] toolbarStrings = new string[] {"Toolbar1", "Toolbar2", "Toolbar3"};

    void OnGUI()
    {
        toolbarInt = GUI.Toolbar(new Rect(25, 25, 250, 30), toolbarInt, toolbarStrings);
    }
}
```

## Toolbar(Rect, int, Texture\[], GUIStyle)

Make a toolbar.

```csharp
public static int Toolbar(Rect position, int selected, Texture[] images, GUIStyle style)
```

### Parameters

**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): Rectangle on the screen to use for the toolbar.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the selected button.**** (\[Texture\[]]\(/engine/6000.0/script-reference/unityengine/texture)): An array of textures on the toolbar buttons.**** (\[GUIStyle]\(/engine/6000.0/script-reference/unityengine/guistyle)): The style to use. If left out, the button style from the current [GUISkin](/engine/6000.0/script-reference/unityengine/guiskin.md) is used.

### Returns

| Type                                                       | Description                       |
| ---------------------------------------------------------- | --------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the selected button. |

### Examples

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

public class ExampleClass : MonoBehaviour
{
    public int toolbarInt = 0;
    public string[] toolbarStrings = new string[] {"Toolbar1", "Toolbar2", "Toolbar3"};

    void OnGUI()
    {
        toolbarInt = GUI.Toolbar(new Rect(25, 25, 250, 30), toolbarInt, toolbarStrings);
    }
}
```

## Toolbar(Rect, int, GUIContent\[], GUIStyle)

Make a toolbar.

```csharp
public static int Toolbar(Rect position, int selected, GUIContent[] contents, GUIStyle style)
```

### Parameters

**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): Rectangle on the screen to use for the toolbar.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the selected button.**** (\[GUIContent\[]]\(/engine/6000.0/script-reference/unityengine/guicontent)): An array of text, image and tooltips for the toolbar buttons.**** (\[GUIStyle]\(/engine/6000.0/script-reference/unityengine/guistyle)): The style to use. If left out, the button style from the current [GUISkin](/engine/6000.0/script-reference/unityengine/guiskin.md) is used.

### Returns

| Type                                                       | Description                       |
| ---------------------------------------------------------- | --------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the selected button. |

### Examples

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

public class ExampleClass : MonoBehaviour
{
    public int toolbarInt = 0;
    public string[] toolbarStrings = new string[] {"Toolbar1", "Toolbar2", "Toolbar3"};

    void OnGUI()
    {
        toolbarInt = GUI.Toolbar(new Rect(25, 25, 250, 30), toolbarInt, toolbarStrings);
    }
}
```

## Toolbar(Rect, int, GUIContent\[], GUIStyle, ToolbarButtonSize)

Make a toolbar.

```csharp
public static int Toolbar(Rect position, int selected, GUIContent[] contents, GUIStyle style, GUI.ToolbarButtonSize buttonSize)
```

### Parameters

**** (\[Rect]\(/engine/6000.0/script-reference/unityengine/rect)): Rectangle on the screen to use for the toolbar.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the selected button.**** (\[GUIContent\[]]\(/engine/6000.0/script-reference/unityengine/guicontent)): An array of text, image and tooltips for the toolbar buttons.**** (\[GUIStyle]\(/engine/6000.0/script-reference/unityengine/guistyle)): The style to use. If left out, the button style from the current [GUISkin](/engine/6000.0/script-reference/unityengine/guiskin.md) is used.**** (\[ToolbarButtonSize]\(/engine/6000.0/script-reference/unityengine/gui/toolbarbuttonsize)): Determines how toolbar button size is calculated.

### Returns

| Type                                                       | Description                       |
| ---------------------------------------------------------- | --------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the selected button. |

### Examples

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

public class ExampleClass : MonoBehaviour
{
    public int toolbarInt = 0;
    public string[] toolbarStrings = new string[] {"Toolbar1", "Toolbar2", "Toolbar3"};

    void OnGUI()
    {
        toolbarInt = GUI.Toolbar(new Rect(25, 25, 250, 30), toolbarInt, toolbarStrings);
    }
}
```
