Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Toolbar

Make a toolbar.
Read time 4 minutesLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.IMGUIModule

Toolbar(Rect, int, string[])

Make a toolbar.
public static int Toolbar(Rect position, int selected, string[] texts)

Parameters

position

Rectangle on the screen to use for the toolbar.

selected

The index of the selected button.

An array of strings to show on the toolbar buttons.

Returns

Type

Description

intThe index of the selected button.

Examples

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.
public static int Toolbar(Rect position, int selected, Texture[] images)

Parameters

position

Rectangle on the screen to use for the toolbar.

selected

The index of the selected button.

images

An array of textures on the toolbar buttons.

Returns

Type

Description

intThe index of the selected button.

Examples

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.
public static int Toolbar(Rect position, int selected, GUIContent[] contents)

Parameters

position

Rectangle on the screen to use for the toolbar.

selected

The index of the selected button.

contents

An array of text, image and tooltips for the toolbar buttons.

Returns

Type

Description

intThe index of the selected button.

Examples

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.
public static int Toolbar(Rect position, int selected, string[] texts, GUIStyle style)

Parameters

position

Rectangle on the screen to use for the toolbar.

selected

The index of the selected button.

An array of strings to show on the toolbar buttons.

The style to use. If left out, the button style from the current GUISkin is used.

Returns

Type

Description

intThe index of the selected button.

Examples

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.
public static int Toolbar(Rect position, int selected, Texture[] images, GUIStyle style)

Parameters

position

Rectangle on the screen to use for the toolbar.

selected

The index of the selected button.

images

An array of textures on the toolbar buttons.

The style to use. If left out, the button style from the current GUISkin is used.

Returns

Type

Description

intThe index of the selected button.

Examples

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.
public static int Toolbar(Rect position, int selected, GUIContent[] contents, GUIStyle style)

Parameters

position

Rectangle on the screen to use for the toolbar.

selected

The index of the selected button.

contents

An array of text, image and tooltips for the toolbar buttons.

The style to use. If left out, the button style from the current GUISkin is used.

Returns

Type

Description

intThe index of the selected button.

Examples

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.
public static int Toolbar(Rect position, int selected, GUIContent[] contents, GUIStyle style, GUI.ToolbarButtonSize buttonSize)

Parameters

position

Rectangle on the screen to use for the toolbar.

selected

The index of the selected button.

contents

An array of text, image and tooltips for the toolbar buttons.

The style to use. If left out, the button style from the current GUISkin is used.

Determines how toolbar button size is calculated.

Returns

Type

Description

intThe index of the selected button.

Examples

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); }}