示例#1
0
 public UITreeData(string name, int layer = 0)
 {
     Name       = name;
     Layer      = layer;
     Parent     = null;
     ChildNodes = new List <UITreeData>();
 }
示例#2
0
 public void SetData(UITreeData rootData)
 {
     if (null == m_container)
     {
         getComponent();
     }
     TreeRootNode.SetData(rootData);
 }
示例#3
0
 public void Inject(UITreeData rootData)
 {
     if (null == m_container)
     {
         getComponent();
     }
     TreeRootNode.Inject(rootData);
 }
示例#4
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));
        }
示例#5
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);
     }
 }
示例#6
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);
 }
示例#7
0
 public UITreeData(string name, List <UITreeData> childNodes, int layer = 0)
 {
     Name       = name;
     Parent     = null;
     ChildNodes = childNodes;
     if (null == ChildNodes)
     {
         ChildNodes = new List <UITreeData>();
     }
     Layer = layer;
     ResetChildren(this);
 }
示例#8
0
        public GameObject pop(UITreeData data, int siblingIndex)
        {
            GameObject treeNode = null;

            if (m_pool.Count > 0)
            {
                treeNode = m_pool[0];
                m_pool.RemoveAt(0);
            }
            else
            {
                treeNode = cloneTreeNode();
            }
            treeNode.transform.SetParent(m_container);
            treeNode.SetActive(true);
            treeNode.GetComponent <UITreeNode>().SetData(data);
            treeNode.transform.SetSiblingIndex(siblingIndex + 1);
            return(treeNode);
        }
 /// <summary>
 /// 赋值后将自动填充显示
 /// </summary>
 /// <param name="data"></param>
 public void SetData(UITreeData data)
 {
     if (null == _myTransform)
     {
         getComponent();
     }
     resetComponent();
     TreeData    = data;
     text.text   = data.Name;
     toggle.isOn = false;
     toggle.onValueChanged.AddListener(openOrClose);
     _container.localPosition += new Vector3(_container.GetComponent <RectTransform>().sizeDelta.y *TreeData.Layer, 0, 0);
     if (data.ChildNodes.Count.Equals(0))
     {
         _toggleTransform.gameObject.SetActive(false);
         icon.sprite = UITree.m_lastLayerIcon;
     }
     else
     {
         icon.sprite = toggle.isOn ? UITree.m_openIcon : UITree.m_closeIcon;
     }
 }
示例#10
0
 public void RemoveChild(UITreeData child)
 {
     RemoveChild(new UITreeData[] { child });
 }
示例#11
0
 public void AddChild(UITreeData child)
 {
     AddChild(new UITreeData[] { child });
 }
示例#12
0
 public void Inject(UITreeData insertData, UITreeData parentData)
 {
 }