private static int DropdownList(Rect position, int current, GUIContent[] items)
    {
        int controlID = GUIUtility.GetControlID(dropdownHash, FocusType.Passive, position);
        var mask      = DropdownCallbackInfo.GetSelectedValueForControl(controlID, current);

        var evt = Event.current;

        if (evt.type == EventType.Repaint)
        {
            if (current >= items.Length || current == -1)
            {
                EditorStyles.popup.Draw(position, new GUIContent("-"), controlID, false);
            }
            else
            {
                EditorStyles.popup.Draw(position, new GUIContent(items[current]), controlID, false);
            }
        }
        else if (evt.type == EventType.MouseDown && position.Contains(evt.mousePosition))
        {
            DropdownCallbackInfo.instance = new DropdownCallbackInfo(controlID);
            GUIUtility.keyboardControl    = GUIUtility.hotControl = 0;
            evt.Use();
            EditorUtility.DisplayCustomMenu(position, items, current,
                                            new EditorUtility.SelectMenuItemFunction(DropdownCallbackInfo.instance.SetMaskValueDelegate), null);
        }

        return(mask);
    }
        public static int GetSelectedValueForControl(int controlID, int index)
        {
            Event current = Event.current;

            if (current.type == EventType.ExecuteCommand && current.commandName == kMaskMenuChangedMessage)
            {
                if (instance == null)
                {
                    Debug.LogError("Mask menu has no instance");
                    return(index);
                }
                else if (instance.controlID == controlID)
                {
                    index                 = instance.selectedIndex;
                    GUI.changed           = true;
                    instance              = null;
                    GUIUtility.hotControl = GUIUtility.keyboardControl = 0;
                    current.Use();
                }
            }

            return(index);
        }
            public static int GetSelectedValueForControl( int controlID, int index )
            {
                Event current = Event.current;

                if ( current.type == EventType.ExecuteCommand && current.commandName == "MaskMenuChanged" ) {
                    if ( instance == null ) {
                        Debug.LogError( "Mask menu has no instance" );
                        return index;
                    } else if ( instance.controlID == controlID ) {
                        index = instance.selectedIndex;

                        GUI.changed = true;

                        instance = null;
                        GUIUtility.hotControl = GUIUtility.keyboardControl = 0;
                        current.Use();
                    }
                }

                return index;
            }