UnityEditor.EditorGUILayout.Popup C# (CSharp) Method

Popup() public static method

Make a generic popup selection field.

public static Popup ( GUIContent label, int selectedIndex, GUIContent displayedOptions ) : int
label UnityEngine.GUIContent Optional label in front of the field.
selectedIndex int The index of the option the field shows.
displayedOptions UnityEngine.GUIContent An array with the options shown in the popup.
return int
        public static int Popup(GUIContent label, int selectedIndex, GUIContent[] displayedOptions, params GUILayoutOption[] options)
        {
            return Popup(label, selectedIndex, displayedOptions, EditorStyles.popup, options);
        }

Same methods

EditorGUILayout::Popup ( GUIContent label, int selectedIndex, GUIContent displayedOptions, GUIStyle style ) : int
EditorGUILayout::Popup ( int selectedIndex, GUIContent displayedOptions ) : int
EditorGUILayout::Popup ( int selectedIndex, GUIContent displayedOptions, GUIStyle style ) : int
EditorGUILayout::Popup ( int selectedIndex, string displayedOptions ) : int
EditorGUILayout::Popup ( int selectedIndex, string displayedOptions, GUIStyle style ) : int
EditorGUILayout::Popup ( string label, int selectedIndex, string displayedOptions ) : int
EditorGUILayout::Popup ( string label, int selectedIndex, string displayedOptions, GUIStyle style ) : int
EditorGUILayout::Popup ( UnityEditor.SerializedProperty property, GUIContent displayedOptions ) : void
EditorGUILayout::Popup ( UnityEditor.SerializedProperty property, GUIContent displayedOptions, GUIContent label ) : void

Usage Example

示例#1
0
        void FromStateFilterInspector(TransitionProfile profile, FromStateFilter filter, ref Rect stateRect)
        {
            EGL.BeginHorizontal();
            filter.type = (FromStateType)EGL.EnumPopup(filter.type, GL.Width(70));

            if (filter.type == FromStateType.State)
            {
                EditorGUIUtil.AutoCompleteList(filter.stateOrTagName, allStateNames, str => filter.stateOrTagName = str, ref stateRect);
            }
            else if (filter.type == FromStateType.Tag)
            {
                EditorGUIUtil.AutoCompleteList(filter.stateOrTagName, transition.profile.tags, str => filter.stateOrTagName = str, ref stateRect);
            }

            if (filter.type == FromStateType.State)
            {
                var state = transition.profile.FindState(filter.stateOrTagName);
                if (state == null)
                {
                    EGL.EndHorizontal();
                    EGL.HelpBox("No Source State", MessageType.Error);
                }
                else
                {
                    List <string> portionSelections = new List <string>();
                    portionSelections.Add("<any>");
                    foreach (var p in state.allPortions)
                    {
                        portionSelections.Add(p.name);
                    }

                    var prevIndex = portionSelections.IndexOf(filter.portionName);
                    if (prevIndex == -1)
                    {
                        prevIndex = 0;
                    }

                    prevIndex          = EGL.Popup(prevIndex, portionSelections.ToArray());
                    filter.portionName = prevIndex == 0 ? "" : portionSelections[prevIndex];

                    if (GL.Button("Focus"))
                    {
                        Utils.FocusEditingAnimation(profile, state.stateName);
                    }
                    EGL.EndHorizontal();
                }
            }
            else
            {
                EGL.EndHorizontal();
            }
        }
All Usage Examples Of UnityEditor.EditorGUILayout::Popup