Esempio n. 1
0
 private void DrawSerach(List <UIElement> list)
 {
     for (int i = 0; i < list.Count; i++)
     {
         GUILayout.BeginHorizontal();
         var node = list[i];
         if (node == SelectNode)
         {
             selectStyle.fixedWidth = position.width;
             GUILayout.Box("", selectStyle);
             GUILayout.Space(-position.width);
         }
         var      ui = node;
         GUIStyle style;
         if (ui.activeSelf)
         {
             style = activeStyle;
         }
         else
         {
             style = defStyle;
         }
         GUILayout.Space(5);
         StringBuilder sb = new StringBuilder();
         var           n  = node;
         while (n.parent != null)
         {
             sb.Insert(0, n.parent.name + "/");
             n = n.parent;
         }
         sb.Append(node.name);
         if (GUILayout.Button(sb.ToString(), style))
         {
             SelectNode = node;
             while (node.parent != null)
             {
                 node.expand = true;
                 node        = node.parent;
             }
             node.expand = true;
             UIInspector.ChangeUI(SelectNode);
         }
         GUILayout.EndHorizontal();
     }
 }
Esempio n. 2
0
    private void DrawTree(UIElement node, int level, bool p)
    {
        if (node == null)
        {
            return;
        }
        GUILayout.BeginHorizontal();
        var ui = node;

        if (mouseDown)
        {
            float a = treeIndex * 16 + 16;
            a -= pos.y;
            if (mousePosition.x >= 0 & mousePosition.x <= position.width)
            {
                if (mousePosition.y >= a & mousePosition.y < a + 16)
                {
                    SelectNode = node;
                }
            }
        }
        if (node == SelectNode)
        {
            selectStyle.fixedWidth = position.width;
            GUILayout.Box("", selectStyle);
            GUILayout.Space(-position.width);
        }
        else
        {
            float a = treeIndex * 16 + 16;
            a -= pos.y;
            if (mousePosition.x >= 0 & mousePosition.x <= position.width)
            {
                if (mousePosition.y >= a & mousePosition.y < a + 16)
                {
                    pointerStyle.fixedWidth = position.width;
                    GUILayout.Box("", pointerStyle);
                    GUILayout.Space(-position.width);
                }
            }
        }
        if (Draing & SelectNode != null)
        {
            float a = treeIndex * 16 + 16;
            float b = a - pos.y;
            if (mousePosition.x >= 0 & mousePosition.x <= position.width)
            {
                if (mousePosition.y >= b & mousePosition.y < b + 16)
                {
                    DockNode = node;
                    if (mousePosition.y < b + 5)
                    {
                        dockPos = 0;
                        dockStyle.fixedHeight = 2;
                        dockStyle.fixedWidth  = position.width;
                        GUI.Box(new Rect(0, a - 18, position.width, 5), "", dockStyle);
                    }
                    else if (mousePosition.y < b + 10)
                    {
                        dockPos = 1;
                        dockStyle.fixedHeight   = 16;
                        pointerStyle.fixedWidth = position.width;
                        GUI.Box(new Rect(0, a - 17, position.width, 16), "", dockStyle);
                    }
                    else
                    {
                        dockPos = 2;
                        dockStyle.fixedHeight = 2;
                        dockStyle.fixedWidth  = position.width;
                        GUI.Box(new Rect(0, a - 2, position.width, 5), "", dockStyle);
                    }
                }
            }
        }
        GUIStyle style;

        if (ui.activeSelf & p)
        {
            style = activeStyle;
        }
        else
        {
            p     = false;
            style = defStyle;
        }

        GUILayout.Space(5 + 14 * level);
        treeIndex++;
        if (node.child.Count > 0)
        {
            if (node.expand)
            {
                style.fixedWidth = 16;
                if (GUILayout.Button("▼ ", style))
                {
                    SelectNode  = node;
                    node.expand = false;
                    UIInspector.ChangeUI(SelectNode);
                }
                style.fixedWidth = 0;
                if (GUILayout.Button(node.name, style))
                {
                    SelectNode = node;
                    UIInspector.ChangeUI(SelectNode);
                }
            }
            else
            {
                style.fixedWidth = 16;
                if (GUILayout.Button("► ", style))
                {
                    SelectNode  = node;
                    node.expand = true;
                    UIInspector.ChangeUI(SelectNode);
                }
                style.fixedWidth = 0;
                if (GUILayout.Button(node.name, style))
                {
                    SelectNode = node;
                    UIInspector.ChangeUI(SelectNode);
                }
            }
        }
        else
        {
            GUILayout.Space(16);
            if (GUILayout.Button(node.name, style))
            {
                SelectNode = node;
                UIInspector.ChangeUI(SelectNode);
            }
        }
        GUILayout.EndHorizontal();
        if (node == null || !node.expand || node.child.Count == 0)
        {
            return;
        }
        for (int i = 0; i < node.child.Count; i++)
        {
            DrawTree(node.child[i], level + 1, p);
        }
    }