Пример #1
0
 public UITreeData(string uid, string name, int layer = 0)
 {
     UID        = uid;
     Name       = name;
     Layer      = layer;
     Parent     = null;
     ChildNodes = new List <UITreeData>();
 }
Пример #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));
        }
Пример #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);
     }
 }
Пример #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);
 }
Пример #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);
 }
Пример #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);
        }
Пример #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;
     }
 }
Пример #8
0
 public void RemoveChild(UITreeData child)
 {
     RemoveChild(new UITreeData[] { child });
 }
Пример #9
0
 public void AddChild(UITreeData child)
 {
     AddChild(new UITreeData[] { child });
 }
Пример #10
0
 public void Inject(UITreeData rootData)
 {
     AddItem(rootData, 0);
 }