Version: 5.3 (switch to 5.4b)
ЯзыкEnglish
  • C#
  • JS

Язык программирования

Выберите подходящий для вас язык программирования. Все примеры кода будут представлены на выбранном языке.

GUI.SelectionGrid

Руководство
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 @param position Прямоугольник на экране для использования сетки.
selected @return Индекс выделенной кнопки.
texts @param texts Массив строк для отображения на кнопках сетки.
images @param images Массив текстур на кнопках сетки.
contents @param contents Массив текста, изображений и подсказок для кнопки сетки.
xCount @param xCount Сколько элементов в горизонтальном направлении. Они будут масштабироваться до величины fixedWidth, определенной в стиле.
style @param style Используемый стиль. Если не задан, то используется стиль из GUISkin.

Возврат значений

int @return Индекс выделенной кнопки.

Описание

Создать сетку(grid) из кнопок.

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() { selGridInt = GUI.SelectionGrid(new Rect(25, 25, 100, 30), selGridInt, selStrings, 2); } }