Version: 5.3 (switch to 5.4b)
IdiomaEnglish
  • C#
  • JS

Idioma de script

Selecciona tu lenguaje de programación favorito. Todos los fragmentos de código serán mostrados en este lenguaje.

EditorGUILayout.Popup

Sugiere un cambio

¡Éxito!

Gracias por ayudarnos a mejorar la calidad de la documentación de Unity. A pesar de que no podemos aceptar todas las sugerencias, leemos cada cambio propuesto por nuestros usuarios y actualizaremos los que sean aplicables.

Cerrar

No se puedo enviar

Por alguna razón su cambio sugerido no pudo ser enviado. Por favor <a>intente nuevamente</a> en unos minutos. Gracias por tomarse un tiempo para ayudarnos a mejorar la calidad de la documentación de Unity.

Cerrar

Cancelar

Cambiar al Manual
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);

Parámetros

label Optional label in front of the field.
selectedIndex The index of the option the field shows.
displayedOptions An array with the options shown in the popup.
style Optional GUIStyle.
options An optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the style.
See Also: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

Valor de retorno

int The index of the option that has been selected by the user.

Descripción

Make a generic popup selection field.

Takes the currently selected index as a parameter and returns the index selected by the user.


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