private void UpdateComponents(ScrollerLine line, float direction) { int nbPerLine = IsVertical ? _maxCount.x : _maxCount.y; int startIndex; if (direction > 0) { startIndex = (_targetLine * nbPerLine) + (_MaxCount * nbPerLine); } else { startIndex = _targetLine * nbPerLine; } int endIndex = startIndex + nbPerLine; int count = 0; for (int i = startIndex; i < endIndex; i++) { if (count < line.components.Count) { if (i < ScrollerManager.GetDatas(_instanceID).Count) { line.components[count].Init(ScrollerManager.GetDatas(_instanceID)[i]); line.components[count].gameObject.SetActive(true); } else { line.components[count].gameObject.SetActive(false); } } count++; } }
private void SwitchLine(bool swap, float direction) { if (swap && direction > 0) { _targetLine++; ScrollerLine line = _lines[0]; _lines.RemoveAt(0); _lines.Add(line); UpdateComponents(line, direction); } else if (swap && direction < 0) { _targetLine--; ScrollerLine line = _lines[_lines.Count - 1]; _lines.RemoveAt(_lines.Count - 1); _lines.Insert(0, line); UpdateComponents(line, direction); } }