void TryOpen() { if (_datas.Count == 0) { return; } ItemBaseInconsist item = GetItem(); item.id = 0; float h = item.SetData(_datas[0]); item.cachedRectTransform.anchoredPosition = new Vector2(0.0f, 0.0f - constHeight); _contextTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, _contextTrans.sizeDelta.y + h); _activeItems.Add(item); item.gameObject.SetActive(true); }
bool NeedCull(ItemBaseInconsist node) { float buffer = 100.0f; if (_activeItems.IndexOf(node) == 0) { if (node.anchoredPosition.y - node.height + _contextTrans.anchoredPosition.y > 0 + buffer) { return(true); } } if (node.anchoredPosition.y + _contextTrans.anchoredPosition.y < -cachedRectTransform.sizeDelta.y - buffer) { return(true); } return(false); }
bool TryAddUp() { int upId = _activeItems[0].id; if (upId == 0) { return(false); } ItemBaseInconsist item = GetItem(); item.id = upId - 1; float h = item.SetData(_datas[upId - 1]); item.cachedRectTransform.anchoredPosition = new Vector2(0.0f, _activeItems[0].anchoredPosition.y + h); _activeItems.Insert(0, item); item.gameObject.SetActive(true); return(true); }
bool TryAddDown() { int downId = _activeItems[_activeItems.Count - 1].id; if (downId == _datas.Count - 1) { return(false); } ItemBaseInconsist item = GetItem(); item.id = downId + 1; float h = item.SetData(_datas[downId + 1]); item.cachedRectTransform.anchoredPosition = new Vector2(0.0f, _activeItems[downId].anchoredPosition.y - _activeItems[downId].height); if (_contextTrans.sizeDelta.y <= -item.anchoredPosition.y + h * 0.5f) { _contextTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, _contextTrans.sizeDelta.y + h); } _activeItems.Add(item); item.gameObject.SetActive(true); return(true); }
void Pool(ItemBaseInconsist node) { _activeItems.Remove(node); node.gameObject.SetActive(false); _pools.Push(node); }
void PoolDown(ItemBaseInconsist node) { Pool(node); //contextTrans.sizeDelta = new Vector2 (contextTrans.sizeDelta.x,contextTrans.sizeDelta.y-node.height); }
void PoolUp(ItemBaseInconsist node) { Pool(node); }