コード例 #1
0
        private void ActivateCell(int index, bool activate)
        {
            Cell cell;

            _activeCells.TryGetValue(index, out cell);

            if (activate)
            {
                var prefab = PrefabAt(index);
                if (cell != null && cell.Prefab != prefab)
                {
                    ReturnCellToPool(cell);
                    cell = null;
                }
                if (cell == null)
                {
                    cell = GetCellFromPool(prefab);
                    _activeCells[index] = cell;
                    PositionCell(cell.View, index);
                }
                if (_source != null)
                {
                    _source.SetItem(cell.View, index);
                }
            }
            else if (cell != null)
            {
                ReturnCellToPool(cell);
                _activeCells.Remove(index);
            }
        }