UnityEditor.GenericMenu.DropDown C# (CSharp) 메소드

DropDown() 공개 메소드

public DropDown ( Rect position ) : void
position UnityEngine.Rect
리턴 void
        public void DropDown(Rect position)
        {
            string[] options = new string[this.menuItems.Count];
            bool[] enabled = new bool[this.menuItems.Count];
            ArrayList list = new ArrayList();
            bool[] separator = new bool[this.menuItems.Count];
            for (int i = 0; i < this.menuItems.Count; i++)
            {
                MenuItem item = (MenuItem) this.menuItems[i];
                options[i] = item.content.text;
                enabled[i] = (item.func != null) || (item.func2 != null);
                separator[i] = item.separator;
                if (item.on)
                {
                    list.Add(i);
                }
            }
            EditorUtility.DisplayCustomMenuWithSeparators(position, options, enabled, separator, (int[]) list.ToArray(typeof(int)), new EditorUtility.SelectMenuItemFunction(this.CatchMenu), null);
        }

Usage Example

        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var left  = position; left.xMax -= 40;
            var right = position; right.xMin = left.xMax + 2;

            EditorGUI.PropertyField(left, property);

            if (GUI.Button(right, "List") == true)
            {
                var menu = new GenericMenu();

                if (LeanLocalization.Instance != null)
                {
                    for (var j = 0; j < LeanLocalization.Instance.Languages.Count; j++)
                    {
                        var language = LeanLocalization.Instance.Languages[j];

                        menu.AddItem(new GUIContent(language), property.stringValue == language, () => { property.stringValue = language; property.serializedObject.ApplyModifiedProperties(); });
                    }
                }

                if (menu.GetItemCount() > 0)
                {
                    menu.DropDown(right);
                }
                else
                {
                    Debug.LogWarning("Your scene doesn't contain any languages, so the language name list couldn't be created.");
                }
            }
        }
All Usage Examples Of UnityEditor.GenericMenu::DropDown