Exemplo n.º 1
0
        public PoolableView Take(int poolId)
        {
            Pool <PoolableView> pool = poolsMap[poolId];

            if (pool.Size <= 0)
            {
                DebugUtils.Log("PoolStorageView.Take(); poolId={0}", poolId);
                DebugUtils.Assert(false);
            }

            PoolableView instance = pool.Take();

            if (instance.DeactivateOnReturn)
            {
                instance.gameObject.SetActive(instance.ActivateOnTake);
            }

            if (instanceContainer != null &&
                instance.transform.parent == instanceContainer)
            {
                instance.transform.SetParent(null, !instance.IsUI);
            }

            instance.IsInPool = false;
            return(instance);
        }
Exemplo n.º 2
0
        private void LateUpdate()
        {
            for (int i = returnList.Count - 1; i >= 0; --i)
            {
                PoolableView instance = returnList[i];
                returnList.RemoveAt(i);

                if (IsInPool(instance))
                {
                    continue;
                }

                Return(instance);
            }
        }
Exemplo n.º 3
0
        public void Return(PoolableView instance)
        {
            DebugUtils.Assert(!IsInPool(instance));
            poolsMap[instance.PoolId].Return(instance);
            GameObject instanceObject = instance.gameObject;

            if (instance.DeactivateOnReturn)
            {
                instance.ActivateOnTake = instanceObject.activeSelf;
                instanceObject.SetActive(false);
            }

            if (instanceContainer != null)
            {
                instance.transform.SetParent(instanceContainer, !instance.IsUI);
            }

            instance.IsInPool = true;
            // DebugUtils.Log("PoolStorageView.Return(); left={0}; instance={1}",
            //     poolsMap[instance.PoolId].available, instance);
        }
Exemplo n.º 4
0
 public void ReturnLater(PoolableView instance)
 {
     returnList.Add(instance);
 }
Exemplo n.º 5
0
 private bool IsInPool(PoolableView instance)
 {
     return(instance.IsInPool);
 }