protected virtual void InitListView() { float sizeDeltaY = 0; float sizeDeltaX = 0; for (int i = 0; i < _source.Length; i++) { if (scrollRect == null || scrollRect.vertical) { if (sizeDeltaY > ViewHeihgt * (mPageCounts + 1)) { if (_itemChildren.Count <= i) { _itemChildren.Add(null); } else { _itemChildren[i] = null; } } else { if (_itemChildren.Count <= i) { _itemChildren.Add(CreateItemRender(_source[i], i)); } else { if (_itemChildren[i] == null) { ItemRender tmpRender = CreateItemRender(_source[i], i); _itemChildren[i] = tmpRender; } else { ResetItemRender(_itemChildren[i], i, _source[i]); } } } sizeDeltaY = (i + 1) * (ItemHeight + m_RowGap) + actualOffsetTop + actualOffsetBottom; } else if (scrollRect.horizontal) { if (sizeDeltaX > ViewWidth * (mPageCounts + 1)) { if (_itemChildren.Count <= i) { _itemChildren.Add(null); } else { _itemChildren[i] = null; } } else { if (_itemChildren.Count <= i) { _itemChildren.Add(CreateItemRender(_source[i], i)); } else { if (_itemChildren[i] == null) { ItemRender tmpRender = CreateItemRender(_source[i], i); _itemChildren[i] = tmpRender; } else { ResetItemRender(_itemChildren[i], i, _source[i]); } } } sizeDeltaX = (i + 1) * (ItemWidth + m_ColGap) + actualOffsetTop + actualOffsetBottom; } } while (_itemChildren.Count > _source.Length) { ItemRender restItem = _itemChildren[_source.Length]; _itemChildren.RemoveAt(_source.Length); if (restItem != null) { _poolManager.DestroyItem(restItem.gameObject); } } preY = _rectTransform.localPosition.y; preX = _rectTransform.localPosition.x; _createChildComplete = true; if (scrollRect == null || scrollRect.vertical) { _rectTransform.sizeDelta = new Vector2(ViewWidth, sizeDeltaY); _rectTransform.offsetMin = new Vector2(0, _rectTransform.offsetMin.y); _rectTransform.offsetMax = new Vector2(0, _rectTransform.offsetMax.y); SetLayoutElement(); MoveToIndex(); AdjustmentItemActiveVertical(); } else if (scrollRect.horizontal) { _rectTransform.sizeDelta = new Vector2(sizeDeltaX, ViewWidth); _rectTransform.offsetMin = new Vector2(_rectTransform.offsetMin.x, 0); _rectTransform.offsetMax = new Vector2(_rectTransform.offsetMax.x, 0); SetLayoutElement(); MoveToIndex(); AdjusetmentItemActiveHorizontal(); } }