Esempio n. 1
0
        static bool DrawBaseHiearchyItem(Rect position, int index, bool expandable, HieararchyGUIElement element)
        {
            bool clicked = false;

            Rect foldoutRect = new Rect(5.0f, 1.0f, 10, position.height - 1.0f);
            Rect nameRect    = new Rect(expandable ? foldoutRect.xMax + 5.0f : 5.0f, 1.0f, position.width - (expandable ? (foldoutRect.xMax + 5.0f) : 0), position.height - 1.0f);

            if (Event.current.type == EventType.MouseDown && (Event.current.button == 0 || Event.current.button == 1))
            {
                if (position.Contains(Event.current.mousePosition))
                {
                    InputManagerWindow.ResetSelections();
                    InputManagerWindow.SetSelection(0, index);

                    clicked = true;

                    GUI.FocusControl(null);
                    InputManagerWindow.instance.Repaint();

                    if (Event.current.button == 1)
                    {
                        element.createContextMenu(new Rect(Event.current.mousePosition, Vector2.zero));
                    }
                }
            }

            GUI.BeginGroup(position);

            if (InputManagerWindow.GetSelection(0) >= 0 && InputManagerWindow.GetSelection(1) < 0 && InputManagerWindow.GetSelection(0) == index)
            {
                GUI.DrawTexture(new Rect(0, 0, position.width, position.height), m_highlightTexture, ScaleMode.StretchToFill);

                if (expandable)
                {
                    schemesExpanded[index] = !EditorGUI.Foldout(foldoutRect, Expanded(index), GUIContent.none);
                }
                EditorGUI.LabelField(nameRect, element.name, m_whiteLabel);
            }
            else
            {
                if (expandable)
                {
                    schemesExpanded[index] = !EditorGUI.Foldout(foldoutRect, Expanded(index), GUIContent.none);
                }
                EditorGUI.LabelField(nameRect, element.name);
            }
            GUI.EndGroup();
            return(clicked);
        }
Esempio n. 2
0
        static bool DrawSubElement(Rect position, int i, int j, HieararchyGUIElement subElement)
        {
            bool clicked  = false;
            Rect nameRect = new Rect(HIERARCHY_INDENT_SIZE, 1.0f, position.width - HIERARCHY_INDENT_SIZE, position.height - 1.0f);

            if (Event.current.type == EventType.MouseDown && (Event.current.button == 0 || Event.current.button == 1))
            {
                if (position.Contains(Event.current.mousePosition))
                {
                    InputManagerWindow.ResetSelections();

                    InputManagerWindow.SetSelection(0, i);
                    InputManagerWindow.SetSelection(1, j);

                    clicked = true;
                    Event.current.Use();
                    GUI.FocusControl(null);
                    InputManagerWindow.instance.Repaint();

                    if (Event.current.button == 1)
                    {
                        subElement.createContextMenu(new Rect(Event.current.mousePosition, Vector2.zero));
                    }
                }
            }

            GUI.BeginGroup(position);
            if (InputManagerWindow.GetSelection(1) >= 0 && InputManagerWindow.GetSelection(0) == i && InputManagerWindow.GetSelection(1) == j)
            {
                GUI.DrawTexture(new Rect(0, 0, position.width, position.height), m_highlightTexture, ScaleMode.StretchToFill);
                EditorGUI.LabelField(nameRect, subElement.name, m_whiteLabel);
            }
            else
            {
                EditorGUI.LabelField(nameRect, subElement.name);
            }
            GUI.EndGroup();

            return(clicked);
        }