Example #1
0
    void SetCellsPool()
    {
        int outSideCount = localCellsPool.Count + cellsInUse.Count - visibleCellsTotalCount;

        if (outSideCount > 0)
        {
            while (outSideCount > 0)
            {
                outSideCount--;
                LinkedListNode <WrapCell> cell = localCellsPool.Last;
                localCellsPool.RemoveLast();
                Destroy(cell.Value.gameObject);
            }
        }
        else if (outSideCount < 0)
        {
            for (int i = 0; i < -outSideCount; i++)
            {
                WrapCell cell = Instantiate <WrapCell>(cellPrefab);
                localCellsPool.AddLast(cell);
                cell.transform.SetParent(scrollRect.content.transform, false);
                cell.Hidden();
            }
        }
    }
Example #2
0
    void ShowCell(int cellIndex, bool scrollingPositive)
    {
        WrapCell tempCell = GetCellFromPool(scrollingPositive);

        if (!isFullLoop)
        {
            if (cellIndex < cellDataList.Count)
            {
                tempCell.SetInfo(cellDataList[cellIndex], cellIndex);
            }
            else
            {
                tempCell.Hidden();
            }
        }
        else
        {
            int realIndexInList = cellIndex % cellDataList.Count;
            if (realIndexInList < 0)
            {
                realIndexInList = cellDataList.Count + realIndexInList;
            }
            tempCell.SetInfo(cellDataList[realIndexInList], realIndexInList);
        }

        PositionCell(tempCell.gameObject, cellIndex);
    }