Esempio n. 1
0
    public override void OnGUI(Rect rect)
    {
        Rect searchBoxRect = new Rect(rect.x, rect.y, rect.width, 36);

        searchBoxRect = new RectOffset(10, 10, 10, 10).Remove(searchBoxRect);
        t             = Kiz_GUIUtility.SearchField(searchBoxRect, t);

        Rect viewRect = rect;

        viewRect.y   += 32;
        viewRect.yMax = rect.yMax;
        mDrawer.Draw(viewRect, mScrollTree);
        editorWindow.Repaint();
    }
Esempio n. 2
0
    void DrawChildren(Rect rect, GUIScrollTree root)
    {
        GUIStyle rightArrow     = new GUIStyle("AC RightArrow");
        GUIStyle leftArrow      = new GUIStyle("AC LeftArrow");
        GUIStyle background     = new GUIStyle("grey_border");
        Rect     scrollViewRect = new Rect(0, 0, rect.width - 20, root.Children.Count * 16);
        Rect     viewRect       = rect;

        viewRect.y   += 20;
        viewRect.yMax = rect.yMax;

        bool mouseRepaint = false;

        switch (Event.current.type)
        {
        case EventType.Repaint:
        {
            mouseRepaint = true;
        }
        break;
        }

        if (!root.isRoot)
        {
            if (GUI.Button(new Rect(rect.x, rect.y, rect.width, 20), root.Name, EditorStyles.miniButtonMid))
            {
                Back(root.Parent.Depth);
            }
            GUI.Box(new Rect(rect.x, rect.y + 4, 16, 12), GUIContent.none, leftArrow);
        }
        else
        {
            GUI.Box(new Rect(rect.x, rect.y, rect.width, 20), root.Name, EditorStyles.miniButtonMid);
        }
        using (var scrollView = new GUI.ScrollViewScope(viewRect, root.GenericValue.mVerticalScrollPos, scrollViewRect))
        {
            Rect nodeRect = new Rect(Vector2.zero, new Vector2(rect.width - GUI.skin.verticalScrollbar.fixedWidth, 16));
            for (int i = 0; i < root.Children.Count; ++i)
            {
                if (mouseRepaint)
                {
                    if (nodeRect.Contains(Event.current.mousePosition))
                    {
                        Rect cu = nodeRect;
                        cu.width = rect.width;
                        Kiz_GUIUtility.DrawSelectRect(cu);
                        mouseRepaint = false;
                    }
                }

                var  child     = root.Children[i];
                Rect nodeRect2 = new RectOffset(12, -12, 0, 0).Remove(nodeRect);
                if (child.isLeaf)
                {
                    if (GUI.Button(nodeRect2, child.Name, EditorStyles.label))
                    {
                        onSelect.Invoke(child);
                    }
                }
                else
                {
                    if (GUI.Button(nodeRect2, child.Name, EditorStyles.label))
                    {
                        SetSelectedIndex(root.Depth, i, child.Depth);
                    }

                    GUI.Label(new Rect(nodeRect2.xMax - 16, nodeRect.y, 16, 16), GUIContent.none, rightArrow);
                }
                nodeRect.y += nodeRect.height;
            }
            root.GenericValue.mVerticalScrollPos = scrollView.scrollPosition;
        }
    }