Esempio n. 1
0
 private void UpdateCell(BaseCell <T> cell, int index)
 {
     cell.dataIndex = index;
     if (cell.dataIndex >= 0 && cell.dataIndex < cellData.Count)
     {
         if (scrollDirection == Direction.Vertical)
         {
             cell.Height = GetCellSize(cell.dataIndex);
         }
         else if (scrollDirection == Direction.Horizontal)
         {
             cell.Width = GetCellSize(cell.dataIndex);
         }
         cell.UpdateContent(cellData[cell.dataIndex]);
         cell.gameObject.SetActive(true);
     }
     else
     {
         cell.gameObject.SetActive(false);
     }
 }
Esempio n. 2
0
        private void MoveCellLastToFirst()
        {
            if (cells.Count == 0)
            {
                return;
            }

            BaseCell <T> lastCell  = cells.Last.Value;
            BaseCell <T> firstCell = cells.First.Value;

            UpdateCell(lastCell, firstCell.dataIndex - 1);

            if (scrollDirection == Direction.Vertical)
            {
                if (scrollReverse)
                {
                    lastCell.Top = firstCell.Bottom - spacing;
                }
                else
                {
                    lastCell.Bottom = firstCell.Top + spacing;
                }
                lastCell.SetOffsetHorizontal(contentPadding.left, contentPadding.right);
            }
            else if (scrollDirection == Direction.Horizontal)
            {
                if (scrollReverse)
                {
                    lastCell.Left = firstCell.Right + spacing;
                }
                else
                {
                    lastCell.Right = firstCell.Left - spacing;
                }
                lastCell.SetOffsetVertical(contentPadding.top, contentPadding.bottom);
            }

            cells.RemoveLast();
            cells.AddFirst(lastCell);
        }