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.EnumPopup

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 EnumPopup(selected: Enum, params options: GUILayoutOption[]): Enum;
public static Enum EnumPopup(Enum selected, params GUILayoutOption[] options);
public static function EnumPopup(selected: Enum, style: GUIStyle, params options: GUILayoutOption[]): Enum;
public static Enum EnumPopup(Enum selected, GUIStyle style, params GUILayoutOption[] options);
public static function EnumPopup(label: string, selected: Enum, params options: GUILayoutOption[]): Enum;
public static Enum EnumPopup(string label, Enum selected, params GUILayoutOption[] options);
public static function EnumPopup(label: string, selected: Enum, style: GUIStyle, params options: GUILayoutOption[]): Enum;
public static Enum EnumPopup(string label, Enum selected, GUIStyle style, params GUILayoutOption[] options);
public static function EnumPopup(label: GUIContent, selected: Enum, params options: GUILayoutOption[]): Enum;
public static Enum EnumPopup(GUIContent label, Enum selected, params GUILayoutOption[] options);
public static function EnumPopup(label: GUIContent, selected: Enum, style: GUIStyle, params options: GUILayoutOption[]): Enum;
public static Enum EnumPopup(GUIContent label, Enum selected, GUIStyle style, params GUILayoutOption[] options);

Parámetros

label Optional label in front of the field.
selected The enum option the field shows.
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

Enum The enum option that has been selected by the user.

Descripción

Make an enum popup selection field.

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


Creates a primitive selected by the user.


        
using UnityEditor;
using UnityEngine;
using System.Collections;

// Creates an instance of a primitive depending on the option selected by the user. public enum OPTIONS { CUBE = 0, SPHERE = 1, PLANE = 2 }

public class EditorGUILayoutEnumPopup : EditorWindow { public OPTIONS op; [MenuItem("Examples/Editor GUILayout Enum Popup usage")] static void Init() { UnityEditor.EditorWindow window = GetWindow(typeof(EditorGUILayoutEnumPopup)); window.Show(); } void OnGUI() { op = (OPTIONS) EditorGUILayout.EnumPopup("Primitive to create:", op); if (GUILayout.Button("Create")) InstantiatePrimitive(op); } void InstantiatePrimitive(OPTIONS op) { switch(op) { case OPTIONS.CUBE: GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.transform.position = Vector3.zero; break; case OPTIONS.SPHERE: GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere.transform.position = Vector3.zero; break; case OPTIONS.PLANE: GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane); plane.transform.position = Vector3.zero; break; default: Debug.LogError("Unrecognized Option"); break; } } }