Example #1
0
 public UITreeData(string uid, string name, int layer = 0)
 {
     UID        = uid;
     Name       = name;
     Layer      = layer;
     Parent     = null;
     ChildNodes = new List <UITreeData>();
 }
Example #2
0
        public override bool Equals(object obj)
        {
            UITreeData other = obj as UITreeData;

            if (null == other)
            {
                return(false);
            }
            return(other.Name.Equals(Name) && other.Layer.Equals(Layer));
        }
Example #3
0
 private void ResetChildren(UITreeData treeData)
 {
     for (int i = 0; i < treeData.ChildNodes.Count; i++)
     {
         UITreeData node = treeData.ChildNodes[i];
         node.Parent = treeData;
         node.Layer  = treeData.Layer + 1;
         ResetChildren(node);
     }
 }
Example #4
0
 public void SetParent(UITreeData parent)
 {
     if (null != this.Parent)
     {
         this.Parent.RemoveChild(this);
     }
     this.Parent = parent;
     this.Layer  = parent.Layer + 1;
     parent.ChildNodes.Add(this);
     ResetChildren(this);
 }
Example #5
0
 public UITreeData(string uid, string name, List <UITreeData> childNodes, int layer = 0)
 {
     UID        = uid;
     Name       = name;
     Parent     = null;
     ChildNodes = childNodes;
     if (null == ChildNodes)
     {
         ChildNodes = new List <UITreeData>();
     }
     Layer = layer;
     ResetChildren(this);
 }
Example #6
0
        public UITreeNode AddItem(UITreeData data, int siblingIndex)
        {
            UITreeNode treeNode = null;

            if (poolList.Count > 0)
            {
                treeNode = poolList[0];
                poolList.RemoveAt(0);
            }
            else
            {
                treeNode = CloneTreeNode();
            }
            treeNode.transform.SetParent(container);
            treeNode.gameObject.SetActive(true);
            treeNode.transform.localScale = Vector3.one;
            treeNode.Inject(data, clickFun);
            treeNode.transform.SetSiblingIndex(siblingIndex + 1);
            return(treeNode);
        }
Example #7
0
 public void Inject(UITreeData data, UnityAction <string> callback)
 {
     if (null == mTransform)
     {
         GetComponent();
     }
     clickFun = callback;
     ResetComponent();
     this.data = data;
     text.text = data.Name;
     button.onClick.AddListener(OpenOrCloseHandle);
     container.localPosition += new Vector3(container.sizeDelta.y * this.data.Layer, 0, 0);
     icon.gameObject.SetActive(true);
     if (IsLeaf)
     {
         icon.sprite = tree.leafIcon;
     }
     else
     {
         icon.sprite = IsOpen ? tree.openIcon : tree.closeIcon;
     }
 }
Example #8
0
 public void RemoveChild(UITreeData child)
 {
     RemoveChild(new UITreeData[] { child });
 }
Example #9
0
 public void AddChild(UITreeData child)
 {
     AddChild(new UITreeData[] { child });
 }
Example #10
0
 public void Inject(UITreeData rootData)
 {
     AddItem(rootData, 0);
 }