Example #1
0
        private void SetBranchData(UTreeNodeData data, UTreeBranch pBranch)
        {
            UTreeBranch branch = GetOneBranch();

            branch.Data = data;
            if (pBranch != null)
            {
                pBranch.SetChild(branch.tran);
            }
            else
            {
                branch.SetParent(content);
            }
            foreach (UTreeNodeData childData in data.Children)
            {
                if (childData.IsBranch)
                {
                    SetBranchData(childData, branch);
                }
                else
                {
                    SetLeafData(childData, branch);
                }
            }
        }
Example #2
0
 private void ResetItemsByNodeData(UTreeNodeData data, UTreeBranch branch)
 {
     if (data.Children != null)
     {
         foreach (UTreeNodeData child in data.Children)
         {
             if (child.IsBranch)
             {
                 UTreeBranch grandBranch = GetOneBranch();
                 grandBranch.Data = child;
                 branch.SetChild(grandBranch.tran);
                 foreach (UTreeNodeData grandChild in child.Children)
                 {
                     ResetItemsByNodeData(grandChild, grandBranch);
                 }
             }
             else
             {
                 UTreeLeaf leaf = GetOneLeaf();
                 //leaf.Data = data;
                 leaf.Data = child;
                 branch.SetChild(leaf.tran);
             }
         }
     }
     else
     {
         UTreeLeaf leaf = GetOneLeaf();
         //leaf.Data = data;
         leaf.Data = data;
         branch.SetChild(leaf.tran);
     }
 }
Example #3
0
 public void AddChild(UTreeNodeData child)
 {
     child.parentData = this;
     childDataList    = childDataList ?? new List <UTreeNodeData>();
     childDataList.Add(child);
     isLeaf = false;
 }
Example #4
0
 //这里处理的是某个节点勾选之后,连带要勾选的逻辑
 public void OnSelectBranch(UTreeNodeData data, bool isSel)
 {
     if (isSel)
     {
         OnSelectParents(data.Parent, isSel);
     }
     OnSelectChildren(data, isSel);
 }
Example #5
0
 //这里处理的是某个节点勾选之后,连带要勾选的逻辑
 public void OnSelectLeaf(UTreeNodeData data, bool isSel)
 {
     data.Check = isSel;
     if (isSel)
     {
         OnSelectParents(data.Parent, isSel);
     }
 }
Example #6
0
        private void SetLeafData(UTreeNodeData data, UTreeBranch branch)
        {
            UTreeLeaf leaf = GetOneLeaf();

            leaf.Data = data;
            if (branch != null)
            {
                branch.SetChild(leaf.tran);
            }
            else
            {
                leaf.SetParent(content);
            }
        }
Example #7
0
 private void OnItemSelected(UTreeNodeData data, bool isSel)
 {
     //这里处理这个节点勾选之后要做的事情,专门指外部处理,例如是显示某个外部的物体
     //if (isSel) {
     //    Debug.Log(" Sbranch " + data.Title);
     //} else {
     //    Debug.Log(" Nbranch " + data.Title);
     //}
     Debug.Log(" branch :" + data.Title + isSel);
     isInvokeInner = false;
     // data.Check = isSel;
     toggle.isOn   = isSel;
     isInvokeInner = true;
 }
Example #8
0
 private void OnSelectParents(UTreeNodeData data, bool isSel)
 {
     if (data != null)
     {
         if (data.connectItem != null && data.connectItem.OnItemSel != null)
         {
             data.connectItem.OnItemSel.Invoke(data, isSel);
             data.Check = isSel;
         }
         if (data.Parent != null)
         {
             OnSelectParents(data.Parent, isSel);
         }
     }
 }
Example #9
0
        //public void OnSelectLeaf(UTreeNodeData data, bool isSel)
        //{
        //    data.Check = isSel;
        //    if (isSel)
        //    {

        //        //Debug.Log(" --S " + data.Title);

        //    }
        //    else {
        //        //Debug.Log(" --N " + data.Title);

        //    }
        //    //Debug.Log(data.Check);
        //}

        //public void OnSelectBranch(UTreeNodeData data, bool isSel)
        //{
        //    data.Check = isSel;
        //    if (isSel)
        //    {
        //        //Debug.Log(" S " + data.Title);
        //    }
        //    else {
        //        //Debug.Log(" N " + data.Title);
        //    }

        //}

        private int GetBranchCount(UTreeNodeData data)
        {
            int branchCount = 0;

            if (data.IsBranch)
            {
                branchCount++;
                foreach (UTreeNodeData branch in data.Children)
                {
                    if (branch.IsBranch)
                    {
                        branchCount += GetBranchCount(branch);
                    }
                }
            }
            return(branchCount);
        }
Example #10
0
 private void OnSelectChildren(UTreeNodeData data, bool isSel)
 {
     if (data != null)
     {
         data.Check = isSel;
         if (data.Children != null)
         {
             foreach (UTreeNodeData child in data.Children)
             {
                 OnSelectChildren(child, isSel);
                 if (child.connectItem != null && child.connectItem.OnItemSel != null)
                 {
                     child.connectItem.OnItemSel.Invoke(child, isSel);
                 }
             }
         }
     }
 }
Example #11
0
        //private UTreeBranch GetBranch(UTreeNodeData data)
        //{

        //    return
        //}

        private int GetLeafCount(UTreeNodeData data)
        {
            int leafCount = 0;

            if (data.IsLeaf)
            {
                leafCount++;
            }
            else
            {
                foreach (UTreeNodeData leaf in data.Children)
                {
                    if (leaf.IsLeaf)
                    {
                        leafCount++;
                    }
                    else
                    {
                        leafCount += GetLeafCount(leaf);
                    }
                }
            }
            return(leafCount);
        }