Beispiel #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);
        }
Beispiel #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);
        }
 bool DrawBaseHiearchyItem(EditorWindow window, Rect position, int index, bool expandable, HieararchyGUIElement element)
 {
     return(DrawHiearchyItem(window, position, index, -1, expandable, element, 5));
 }
 bool DrawSubElement(EditorWindow window, Rect position, int i, int j, HieararchyGUIElement subElement)
 {
     return(DrawHiearchyItem(window, position, i, j, false, subElement, 30));
 }
        bool DrawHiearchyItem(EditorWindow window, Rect pos, int i, int j, bool expandable, HieararchyGUIElement element, float indent)
        {
            bool clicked = false;

            if (Event.current.type == EventType.MouseDown && (Event.current.button == 0 || Event.current.button == 1))
            {
                if (pos.Contains(Event.current.mousePosition))
                {
                    selections[0] = i;
                    selections[1] = j;

                    clicked = true;

                    GUI.FocusControl(null);
                    window.Repaint();

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

            float foldoutWidth = 10;

            if (expandable)
            {
                itemsExpanded[i] = !EditorGUI.Foldout(new Rect(pos.x + indent, pos.y, foldoutWidth, pos.height), Expanded(i), GUITools.noContent);
            }

            float offset   = expandable ? foldoutWidth + indent : indent;
            Rect  nameRect = new Rect(pos.x + offset, pos.y, pos.width - offset, pos.height);

            bool isSelected = selections[0] == i && selections[1] == j;

            if (isSelected)
            {
                GUI.DrawTexture(pos, m_highlightTexture, ScaleMode.StretchToFill);
            }

            GUITools.Label(nameRect, element.name, isSelected ? GUITools.white : GUITools.black, GUITools.label);


            return(clicked);
        }