private void MoveCellsToBack(int count) { if (count > m_Cells.Count) { count = m_Cells.Count; } for (int i = 0; i < count; i++) { ScrollViewCell cell = m_Cells[0]; m_Cells.RemoveAt(0); m_Cells.Insert(m_Cells.Count, cell); } for (int i = 0; i < count; i++) { SetCellAnchoredPosition(m_Cells.Count - i - 1); SetData(m_Cells.Count - i - 1); } }
private void MoveCellsToFront(int count) { if (count > m_Cells.Count) { count = m_Cells.Count; } for (int i = 0; i < count; i++) { ScrollViewCell cell = m_Cells[m_Cells.Count - 1]; m_Cells.RemoveAt(m_Cells.Count - 1); m_Cells.Insert(0, cell); } for (int i = 0; i < count; i++) { SetCellAnchoredPosition(i); SetData(i); } }
private void PopCellFromPool(int count) { while (count - m_CellPool.Count > 0) { GameObject gameObject = Instantiate(m_DefaultItem.gameObject, m_DefaultItem.transform.position, Quaternion.identity, m_DefaultItem.transform.parent); ScrollViewCell cell = m_CellType == null ? new ScrollViewCell() : Activator.CreateInstance(m_CellType) as ScrollViewCell; cell.Init(gameObject); m_CellPool.Add(cell); } List <ScrollViewCell> cells = m_CellPool.GetRange(0, count); m_Cells.AddRange(cells); m_CellPool.RemoveRange(0, count); foreach (ScrollViewCell cell in cells) { cell.Wakeup(); } }