示例#1
0
    protected virtual void Despawn(RectTransform container)
    {
        if (!ContainerCellData.ContainsKey(container))
        {
            return;
        }

        AbstractCellData cellData = ContainerCellData[container];

        if (cellData.CellControllerRef == null)
        {
            return;
        }

        AbstractCellController cellController = cellData.CellControllerRef;

        if (!ReusableCellPool.ContainsKey(cellController.GetType()))
        {
            ReusableCellPool.Add(cellController.GetType(), new List <AbstractCellController>());
        }

        ReusableCellPool[cellController.GetType()].Insert(0, cellController);
        if (NoDeactivations)
        {
            cellController.transform.SetParent(null, false);
        }
        else
        {
            cellController.gameObject.SetActive(false);

            cellController.transform.SetParent(transform, false);
            cellController.transform.SetSiblingIndex(-1000);
        }
        cellController.enabled = false;

        if (cellData.OnDespawn != null)
        {
            cellData.OnDespawn(cellData);
        }

        cellData.CellControllerRef = null;

        ContainerCellData.Remove(container);
    }
示例#2
0
    protected override AbstractCellController GetFirstInactiveReusableCell(Type type)
    {
        if (ReusableCellPool.ContainsKey(type))
        {
            List <AbstractCellController> reusableControllerList = ReusableCellPool[type];
            if (reusableControllerList.Count > 0)
            {
                AbstractCellController cellController = reusableControllerList[0];
                ReusableCellPool[cellController.GetType()].Remove(cellController);
                cellController.enabled = true;
                if (!NoDeactivations)
                {
                    cellController.gameObject.SetActive(true);
                }
                return(cellController);
            }
        }

        return(null);
    }