Ejemplo n.º 1
0
 void showCell(int cellIndex, bool scrollingPositive)
 {
     if (cellIndex < allData.Count)
     {
         ScrollCell tempCell = getCellFromPool(scrollingPositive);
         positionCell(tempCell.gameObject, cellIndex);
         tempCell.init(this, allData[cellIndex], cellIndex);
         tempCell.configureCellData();
     }
 }
    public void AddCell(string text)
    {
        var cell = GetNextRecycledCell();

        var rngText = Guid.NewGuid().ToString();

        cell.SetDisplay(rngText);

        cell.RectTransform.SetAsLastSibling();

        if (Anchored)
        {
            ScrollRect.verticalNormalizedPosition = 0f;
        }

        ActiveCells.Enqueue(cell);
        LastActiveCell = cell;
    }
Ejemplo n.º 3
0
    public void refresh(bool force)    //foere = false 表示如果引用同一个对象,则不对内容进行刷新,对只引用判断无效
    {
        setContentSize();
        computeFirstVisIndex();
        preFirstVisibleIndex = firstVisibleIndex;
        LinkedListNode <ScrollCell> cell = cellsInUse.First;
        int effectCount = 0;

        for (int i = 0; i < showCellCount(); i++)
        {
            var cellIndex = firstVisibleIndex * numOfColumns + i;
            if (cellIndex < allData.Count)
            {
                effectCount++;
                ScrollCell scrollCell = null;
                if (cell == null)
                {
                    scrollCell = getCellFromPool(true);
                    positionCell(scrollCell.gameObject, cellIndex);
                }
                else
                {
                    scrollCell = cell.Value;
                    cell       = cell.Next;
                }
                if (force || scrollCell.DataObject != allData[cellIndex])
                {
                    positionCell(scrollCell.gameObject, cellIndex);
                    scrollCell.init(this, allData[cellIndex], cellIndex);
                    scrollCell.configureCellData();
                }
            }
        }
        while (cellsInUse.Count - effectCount > 0)
        {
            freeCell(false);
        }
    }