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

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

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

EditorGUILayout.Popup

Предложить изменения

Успех!

Благодарим вас за то, что вы помогаете нам улучшить качество документации по Unity. Однако, мы не можем принять любой перевод. Мы проверяем каждый предложенный вами вариант перевода и принимаем его только если он соответствует оригиналу.

Закрыть

Ошибка внесения изменений

По определённым причинам предложенный вами перевод не может быть принят. Пожалуйста <a>попробуйте снова</a> через пару минут. И выражаем вам свою благодарность за то, что вы уделяете время, чтобы улучшить документацию по Unity.

Закрыть

Отменить

Руководство
public static function Popup(selectedIndex: int, displayedOptions: string[], params options: GUILayoutOption[]): int;
public static int Popup(int selectedIndex, string[] displayedOptions, params GUILayoutOption[] options);
public static function Popup(selectedIndex: int, displayedOptions: string[], style: GUIStyle, params options: GUILayoutOption[]): int;
public static int Popup(int selectedIndex, string[] displayedOptions, GUIStyle style, params GUILayoutOption[] options);
public static function Popup(selectedIndex: int, displayedOptions: GUIContent[], params options: GUILayoutOption[]): int;
public static int Popup(int selectedIndex, GUIContent[] displayedOptions, params GUILayoutOption[] options);
public static function Popup(selectedIndex: int, displayedOptions: GUIContent[], style: GUIStyle, params options: GUILayoutOption[]): int;
public static int Popup(int selectedIndex, GUIContent[] displayedOptions, GUIStyle style, params GUILayoutOption[] options);
public static function Popup(label: string, selectedIndex: int, displayedOptions: string[], params options: GUILayoutOption[]): int;
public static int Popup(string label, int selectedIndex, string[] displayedOptions, params GUILayoutOption[] options);
public static function Popup(label: string, selectedIndex: int, displayedOptions: string[], style: GUIStyle, params options: GUILayoutOption[]): int;
public static int Popup(string label, int selectedIndex, string[] displayedOptions, GUIStyle style, params GUILayoutOption[] options);
public static function Popup(label: GUIContent, selectedIndex: int, displayedOptions: GUIContent[], params options: GUILayoutOption[]): int;
public static int Popup(GUIContent label, int selectedIndex, GUIContent[] displayedOptions, params GUILayoutOption[] options);
public static function Popup(label: GUIContent, selectedIndex: int, displayedOptions: GUIContent[], style: GUIStyle, params options: GUILayoutOption[]): int;
public static int Popup(GUIContent label, int selectedIndex, GUIContent[] displayedOptions, GUIStyle style, params GUILayoutOption[] options);

Параметры

label @param label Необязательный текст перед полем.
selectedIndex @param selected Значение enum показываемое в поле как выбранное.
displayedOptions An array with the options shown in the popup.
style @param style Необязательный стиль GUIStyle.
options @param options Настраиваемый список настроек слоя, который определяет дополнительные свойства слоя. Любые значения, переданные здесь, будут переопределять настройки, определенный стилем. See Also: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

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

int @return Значение перечисления enum которое было выбрано пользователем.

Описание

Make a generic popup selection field.

Получает текущее значение enum в качестве параметра, и возвращает значение enum, выбранное пользователем.


Create a primitive depending on the option selected.


        
using UnityEditor;
using UnityEngine;
using System.Collections;

// Creates an instance of a primitive depending on the option selected by the user. public class EditorGUILayoutPopup : EditorWindow { public string[] options = new string[] {"Cube", "Sphere", "Plane"}; public int index = 0; [MenuItem("Examples/Editor GUILayout Popup usage")] static void Init() { EditorWindow window = GetWindow(typeof(EditorGUILayoutPopup)); window.Show(); } void OnGUI() { index = EditorGUILayout.Popup(index, options); if (GUILayout.Button("Create")) InstantiatePrimitive(); } void InstantiatePrimitive() { switch(index) { case 0: GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.transform.position = Vector3.zero; break; case 1: GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere.transform.position = Vector3.zero; break; case 2: GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane); plane.transform.position = Vector3.zero; break; default: Debug.LogError("Unrecognized Option"); break; } } }