public virtual void ResetItems() { CTreeNode branchItem; TotalHeight = 0; if (_branchUsedList == null) { return; } for (int i = 0; i < _dataProvider.Count; i++) { branchItem = _branchUsedList[i]; branchItem.name = "Item" + i; branchItem.data = _dataProvider[i]; float itemY; itemY = -TotalHeight; branchItem.tran.localPosition = new Vector3(0, itemY, 0); EventUtil.AddHover(branchItem.go, OnItemHover); EventUtil.AddPress(branchItem.go, OnItemHover); UIEventListener listener = UIEventListener.Get(branchItem.go); listener.onHover = OnItemHover; listener.onPress = OnItemPress; TotalHeight += branchHeight + branchGapU; CheckOpenAndResetChilde(branchItem); } //spSelected.gameObject.SetActive(!clearAllLeaf); CalculateHeight(TotalHeight); int barWidth = 0; if (Bar.gameObject.activeSelf == true) { barWidth = Bar.width; } Overlay.width = this.width - barWidth; spSelected.width = this.width - barWidth; Content.baseClipRegion = new Vector4((this.width - barWidth) / 2, -this.height / 2, this.width - barWidth, this.height); }
protected virtual void ResetItems() { CTreeNode branchItem; TotalHeight = 0; bool clearAllLeaf = true; int chlidLen = 0; if (_branchUsedList == null) { return; } for (int i = 0; i < _branchUsedList.Count; i++) { branchItem = _branchUsedList[i]; branchItem.name = "Item" + i; branchItem.data = _dataProvider[i]; float itemY; itemY = -TotalHeight; branchItem.tran.localPosition = new Vector3(0, itemY, 0); EventUtil.AddHover(branchItem.go, OnItemHover); EventUtil.AddPress(branchItem.go, OnItemHover); UIEventListener listener = UIEventListener.Get(branchItem.go); listener.onHover = OnItemHover; listener.onPress = OnItemPress; TotalHeight += branchHeight + branchGapU; if (branchItem.isOpen) { int startIndex = chlidLen; if (branchItem.data.child != null) { chlidLen += branchItem.data.child.Count; } if (chlidLen > 0) { clearAllLeaf = false; } for (int n = 0; (n + startIndex) < chlidLen; n++) { CTreeNode child; if ((n + startIndex) < _leafUsedList.Count) { child = _leafUsedList[n + startIndex]; } else { child = GetLeaf(); } child.name = "Item" + i; child.SetParent(Content.transform); child.SetActive(true); child.data = branchItem.data.child[n]; float childY; childY = -TotalHeight; child.tran.localPosition = new Vector3(0, childY, 0); UIEventListener childListener = UIEventListener.Get(child.go); childListener.onHover = OnItemHover; childListener.onPress = OnItemPress; TotalHeight += _leafHeight + leafGapU; } } } if (chlidLen < _leafUsedList.Count) { for (int j = _leafUsedList.Count - 1; j >= chlidLen; j--) { CTreeNode temp = _leafUsedList[j]; temp.SetParent(Recycle); _leafPool.Add(temp); _leafUsedList.Remove(temp); } } if (clearAllLeaf) { for (int j = _leafUsedList.Count - 1; j >= 0; j--) { CTreeNode temp = _leafUsedList[j]; temp.SetParent(Recycle); _leafPool.Add(temp); _leafUsedList.Remove(temp); } } spSelected.gameObject.SetActive(!clearAllLeaf); //if (_dataProvider == null) { // TotalHeight = 0; //} else { // float itemH = _branchHeight * _dataProvider.Count / float.Parse(ColNum.ToString()); // TotalHeight = PaddingTop + Mathf.CeilToInt(itemH) + PaddingBottom; //} //Bar.gameObject.SetActive(TotalHeight > height); //if (Bar.gameObject.activeSelf == true) { // Bar.BarSize = (float)this.height / TotalHeight; //} CalculateHeight(TotalHeight); int barWidth = 0; if (Bar.gameObject.activeSelf == true) { barWidth = Bar.width; } Overlay.width = this.width - barWidth; spSelected.width = this.width - barWidth; Content.baseClipRegion = new Vector4((this.width - barWidth) / 2, -this.height / 2, this.width - barWidth, this.height); }