Exemplo n.º 1
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="arr"></param>
        /// <param name="parent"></param>
        /// <returns></returns>
        public IEnumerator Init(GameObjectPoolEntity[] arr, Transform parent)
        {
            int len = arr.Length;

            for (int i = 0; i < len; i++)
            {
                GameObjectPoolEntity entity = arr[i];

                if (entity.Pool != null)
                {
                    UnityEngine.Object.Destroy(entity.Pool.gameObject);
                    yield return(null);

                    entity.Pool = null;
                }

                //创建对象池
                PathologicalGames.SpawnPool pool = PathologicalGames.PoolManager.Pools.Create(entity.PoolName);
                pool.group.parent        = parent;
                pool.group.localPosition = Vector3.zero;
                entity.Pool = pool;

                m_SpawnPoolDic[entity.PoolId] = entity;
            }
        }
Exemplo n.º 2
0
 public virtual void RemoveSelf()
 {
     if (MyModel != null)
     {
         PathologicalGames.SpawnPool spawnPool = ActorManager.Instance.EffectSpawnPool;
         if (spawnPool.IsSpawned(MyModel.transform))
         {
             spawnPool.Despawn(MyModel.transform);
             MyModel = null;
         }
         else
         {
             Debug.LogError("检查一下为什么没有调用对象池");
         }
     }
 }
Exemplo n.º 3
0
 private void _Despawn()
 {
     PathologicalGames.SpawnPool pool =
         PathologicalGames.PoolManager.Pools.ContainsKey(originSpawnPoolName)
                         ? PathologicalGames.PoolManager.Pools[originSpawnPoolName]
                         : null;
     if (pool != null && pool.IsSpawned(this.transform))
     {
         pool.Despawn(this.transform);
     }
     else
     {
         Debug.LogWarning("Object spawned outside of pool; unable to despawn, so destroying object instead.", this.gameObject);
         Destroy(this.gameObject);
     }
 }