protected void SetCTChildNode(UWarGoodsStoreTreeNodeData _nNode, int _index)
        {
            int minusCount = 0;
            //同级所有节点所占的宽度
            int ChildsWidth = (int)_nNode.GoodsNodeComponent.width * _nNode.ParentNode.GoodsChildCount;
            int ParentWidth = _nNode.ParentNode.ParentNodeWidth;

            //计算当前子级所有节点所占的宽度是否超出父级宽度
            while (ParentWidth < ChildsWidth)
            {
                minusCount++;
                ChildsWidth = (int)_nNode.GoodsNodeComponent.width * (_nNode.ParentNode.GoodsChildCount - minusCount);
            }

            _nNode.ParentNodeWidth = (_nNode.ParentNode.ParentNodeWidth) / (_nNode.ParentNode.GoodsChildCount - minusCount);

            //从父节点中点到左边距离开始算起
            int   px      = (int)(_nNode.ParentNode.GoodsNodeComponent.x + _nNode.ParentNode.GoodsNodeComponent.width / 2) - (_nNode.ParentNode.ParentNodeWidth / 2);
            float XOffset = 0.5f;

            //同级节点为偶数则偏移半个节点位置,否则不偏移
            if (minusCount > 0)
            {
                XOffset = _nNode.ParentNode.GoodsChildCount % 2 == 0 ? 0.5f : 0;
            }

            _nNode.GoodsNodeComponent.x = px + (_nNode.ParentNodeWidth * (_index + XOffset)) - (_nNode.GoodsNodeComponent.width / 2);
            _nNode.GoodsNodeComponent.y = _nNode.ParentNode.GoodsNodeComponent.y - _nNode.ParentNode.GoodsNodeComponent.height;
            _nNode.GoodsNodeComponent.SetParentVerticalLineVisible(true);
            _nNode.GoodsNodeComponent.SetChildVerticalLineVisible(_nNode.GoodsChildCount == 0 ? false : true);

            if (_nNode.GoodsChildCount == 0)
            {
                return;
            }


            if (_nNode.ChildsNodeList == null)
            {
                _nNode.ChildsNodeList = new List <UWarGoodsStoreTreeNodeData>();
            }
            else
            {
                _nNode.ChildsNodeList.Clear();
            }



            for (int i = 0; i < _nNode.GoodsChildCount; i++)
            {
                UWarGoodsStoreTreeNodeData nextNode = GetCurrentNode();
                nextNode.ParentNode = _nNode;
                _nNode.ChildsNodeList.Add(nextNode);
                GetUnuseTreeNodeEx(out nextNode.GoodsNodeComponent);

                SetCTChildNode(nextNode, i);
            }
        }
        protected UWarGoodsStoreTreeNodeData GetCurrentNode()
        {
            m_CurNodeDataIndex++;
            if (m_CurNodeDataIndex >= UseTreeNodeDataList.Count)
            {
                Debug.LogWarning("超出范围了");
                return(null);
            }
            UWarGoodsStoreTreeNodeData _nNode = UseTreeNodeDataList[m_CurNodeDataIndex];

            return(_nNode);
        }
 public void Clear()
 {
     GoodsDepth         = 0;
     GoodsChildCount    = 0;
     ParentNode         = null;
     GoodsItem          = null;
     GoodsNodeComponent = null;
     if (ChildsNodeList != null)
     {
         ChildsNodeList.Clear();
     }
     ParentNodeWidth = 0;
 }
        protected void SetCTRootNode()
        {
            UWarGoodsStoreTreeNodeData _nNode = GetCurrentNode();

            _nNode.ParentNodeWidth = (int)ViewRect.width;

            GetUnuseTreeNodeEx(out _nNode.GoodsNodeComponent);

            _nNode.GoodsNodeComponent.x = (_nNode.ParentNodeWidth / 2) - (_nNode.GoodsNodeComponent.width / 2);
            _nNode.GoodsNodeComponent.y = 0;
            _nNode.GoodsNodeComponent.SetParentVerticalLineVisible(false);
            _nNode.GoodsNodeComponent.SetChildVerticalLineVisible(_nNode.GoodsChildCount == 0 ? false : true);

            if (_nNode.GoodsChildCount == 0)
            {
                return;
            }

            if (_nNode.ChildsNodeList == null)
            {
                _nNode.ChildsNodeList = new List <UWarGoodsStoreTreeNodeData>();
            }
            else
            {
                _nNode.ChildsNodeList.Clear();
            }

            for (int i = 0; i < _nNode.GoodsChildCount; i++)
            {
                UWarGoodsStoreTreeNodeData nextNode = GetCurrentNode();
                nextNode.ParentNode = _nNode;
                GetUnuseTreeNodeEx(out nextNode.GoodsNodeComponent);
                _nNode.ChildsNodeList.Add(nextNode);

                SetCTChildNode(nextNode, i);
            }
        }
        protected bool GetUnuseTreeNodeData(out UWarGoodsStoreTreeNodeData _nUnuseNodeData)
        {
            UWarGoodsStoreTreeNodeData node;

            //先从缓冲中取
            if (UnuseTreeNodeDataList.Count > 0)
            {
                node = UnuseTreeNodeDataList[UnuseTreeNodeDataList.Count - 1];
                UnuseTreeNodeDataList.Remove(node);
                UseTreeNodeDataList.Add(node);
                _nUnuseNodeData = node;

                return(true);
            }

            InstantiateTreeNodeData();

            node = UnuseTreeNodeDataList[UnuseTreeNodeDataList.Count - 1];
            UnuseTreeNodeDataList.Remove(node);
            UseTreeNodeDataList.Add(node);
            _nUnuseNodeData = node;

            return(true);
        }
        protected void InstantiateTreeNodeData()
        {
            UWarGoodsStoreTreeNodeData newNode = new UWarGoodsStoreTreeNodeData();

            UnuseTreeNodeDataList.Add(newNode);
        }