示例#1
0
文件: ScrollView.cs 项目: eyilee/misc
        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);
            }
        }
示例#2
0
文件: ScrollView.cs 项目: eyilee/misc
        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);
            }
        }
示例#3
0
文件: ScrollView.cs 项目: eyilee/misc
        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();
            }
        }