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