Ejemplo n.º 1
0
    void DrawRequirementDropdown(EHand Hand, ref bool OutDropDownOpen, GenericMenu.MenuFunction2 AddFunc)
    {
        GUIStyle RemoveButton = new GUIStyle(GUI.skin.label)
        {
            alignment    = TextAnchor.MiddleLeft,
            stretchWidth = false
        };

        GUIStyle ExtrasButton = new GUIStyle(GUI.skin.button)
        {
            alignment    = TextAnchor.MiddleLeft,
            stretchWidth = false
        };

        GUIStyle LabelText = new GUIStyle(GUI.skin.label)
        {
            alignment = TextAnchor.MiddleCenter,
            fontSize  = 20,
            fontStyle = FontStyle.Bold
        };

        GUIStyle BorderStyle = new GUIStyle(EditorStyles.helpBox)
        {
            margin = new RectOffset(1, 1, 1, 1)
        };

        GUI.backgroundColor = Color.black;
        EditorGUILayout.BeginHorizontal(BorderStyle);
        GUI.backgroundColor = Color.white;
        EditorGUILayout.BeginHorizontal(BorderStyle);
        if (GUILayout.Button(OutDropDownOpen ? CustomGestureIcons.LoadDownArrow() : CustomGestureIcons.LoadRightArrow(), RemoveButton, GUILayout.Width(25), GUILayout.Height(25)))
        {
            OutDropDownOpen = !OutDropDownOpen;
        }

        GUILayout.Label((Hand == EHand.eLeftHand ? "Left" : "Right") + " Hand Requirements", LabelText);

        GUI.backgroundColor = Color.green;
        if (GUILayout.Button(CustomGestureIcons.LoadPlusIcon(), ExtrasButton, GUILayout.Width(25), GUILayout.Height(25)))
        {
            GenericMenu AddMenu = new GenericMenu();

            GestureRequirement[] AllRequirements = TargetGesture.GetListOfAllRequirements();
            foreach (GestureRequirement require in AllRequirements)
            {
                AddMenu.AddItem(new GUIContent(require.GetName()), false, AddFunc, require);
                AddMenu.AddSeparator("");

                AddMenu.ShowAsContext();
            }
        }
        GUI.backgroundColor = Color.white;
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndHorizontal();

        if (OutDropDownOpen)
        {
            List <GestureRequirementData> Requirements = TargetGesture.GetHandRequirements(Hand);

            SerializedProperty HandReqProp;

            if (Hand == EHand.eLeftHand)
            {
                HandReqProp = serializedObject.FindProperty("LeftHandRequirements");
            }
            else
            {
                HandReqProp = serializedObject.FindProperty("RightHandRequirements");
            }

            DrawCustomGestureDropdown(Requirements, Hand, HandReqProp);
        }
    }