Объявление
public static int SelectionGrid(Rect position, int selected, string[] texts, int xCount);public static int SelectionGrid(Rect position, int selected, Texture[] images, int xCount);
public static int SelectionGrid(Rect position, int selected, GUIContent[] content, int xCount);
public static int SelectionGrid(Rect position, int selected, string[] texts, int xCount, GUIStyle style);
public static int SelectionGrid(Rect position, int selected, Texture[] images, int xCount, GUIStyle style);
public static int SelectionGrid(Rect position, int selected, GUIContent[] contents, int xCount, GUIStyle style);
Параметры
position | Прямоугольник на экране для использования в качестве сетки. |
selected | Индекс выбранной кнопки сетки. |
texts | Массив строк для отображения на кнопках сетки. |
images | Массив текстур на кнопках сетки. |
contents | Массив текста, изображения и всплывающих подсказок для кнопки сетки. |
xCount | Сколько элементов уместить в горизонтальном направлении. Элементы управления будут масштабироваться по размеру, если только стиль не определяет фиксированную ширину для использования. |
style | Используемый стиль. Если его не указать, используется стиль кнопки из текущего GUISkin. |
Возвращает
int Индекс выбранной кнопки.
Описание
Создайте сетку из кнопок.
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour
{
public int selGridInt = 0;
public string[] selStrings = new string[] {"Grid 1", "Grid 2", "Grid 3", "Grid 4"};
void OnGUI()
{
// use 2 elements in the horizontal direction
selGridInt = GUI.SelectionGrid(new Rect(25, 25, 100, 30), selGridInt, selStrings, 2);
}
}