public void Refill() { currentContentSize = 0; currentCount = 0; foreach (var y in entry) { SwitchT(y.item, false); } entry.RemoveAll(); Entry <T> e; int t = 0, k = 0; paddedSize = headPadding; //TODO head padding paddedSize += viewportSize; while (t < targetCount && currentContentSize < paddedSize) { e = ActivateEntry(entry.Add()); e.info = FillT(t + indexOffset, e.item); e.transform.anchoredPosition = Repos(t, 0); ++t; ++currentCount; if (++k == elementPerLine) { currentContentSize += e.info.size; k = 0; } } paddedSize += tailPadding; //tail padding while (t < targetCount && currentContentSize < paddedSize) { //TODO same code e = ActivateEntry(entry.Add()); e.info = FillT(t + indexOffset, e.item); e.transform.anchoredPosition = Repos(t, 0); ++t; ++currentCount; if (++k == elementPerLine) { currentContentSize += e.info.size; k = 0; } } posFixed = t == targetCount && currentContentSize <= viewportSize; tailCount = k == 0 ? elementPerLine : k; RefreshContentSize(); }
public void Refit(int count_) { targetCount = count_; lineCountViewport = Mathf.CeilToInt(viewportSize / elementSize) + 1; int lineCountContent = Mathf.CeilToInt((float)targetCount / elementPerLine); //Debug.Log(lineCountContent + " " + lineCountViewport); posFixed = lineCountContent < lineCountViewport; LineScrollRange = lineCountContent - lineCountViewport; RefreshContentSize(lineCountContent * elementSize); entryCount = lineCountViewport * elementPerLine; entryCount = entryCount < targetCount ? entryCount : targetCount; for (int r = 0; r < entry.Count; ++r) { SwitchT(entry[r].item, false); } entry.RemoveAll(); for (int u = 0; u < entryCount; ++u) { SwitchT(entry.Add().item, true); } }