public virtual void SetData(List <TData> dataProviders) { base.SetData(dataProviders); _mapper = new VirtualizedListMapper(View.ListScroller.NumRenderers, dataProviders.Count); View.ListScroller.UpdateAfterSettingData(dataProviders.Count); //fill mediators with data for (var i = 0; i < _mapper.ViewCount; i++) { var mediator = GetMediatorAt(i); if (i >= _visibleMediatorsCount) { mediator.SetActive(true); } SetItemData(mediator, dataProviders[i], i); } //hide remaining item renderers for (var i = _mapper.ViewCount; i < ItemMediators.Count; i++) { ItemMediators[i].SetActive(false); } _visibleMediatorsCount = _mapper.ViewCount; }
public void UpdateAfterSettingData(int dataprovidersCount) { _mapper = new VirtualizedListMapper(NumRenderers, dataprovidersCount); //update item pos for (var i = 0; i < _mapper.ViewCount; i++) { UpdateItemPos(i); } UpdateContentSize(); //reset position _content.anchoredPosition = Vector2.zero; }