public static int Toolbar (Rect position, int selected, string[] texts);
public static int Toolbar (Rect position, int selected, Texture[] images);
public static int Toolbar (Rect position, int selected, GUIContent[] contents);
public static int Toolbar (Rect position, int selected, string[] texts, GUIStyle style);
public static int Toolbar (Rect position, int selected, Texture[] images, GUIStyle style);
public static int Toolbar (Rect position, int selected, GUIContent[] contents, GUIStyle style);
public static int Toolbar (Rect position, int selected, GUIContent[] contents, GUIStyle style, GUI.ToolbarButtonSize buttonSize);

参数

position屏幕上用于工具栏的矩形。
selected所选按钮的索引。
texts要在工具栏按钮上显示的字符串的数组。
images工具栏按钮上的纹理的数组。
contents工具栏按钮的文本、图像和工具提示的数组。
style要使用的样式。如果省略,则使用当前 GUISkinbutton 样式。
buttonSize确定计算工具栏按钮大小的方式。

返回

int 所选按钮的索引。

描述

创建一个工具栏。

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