Exemplo n.º 1
0
 /// <summary>
 /// Despawn the specified PoolableObject.
 /// </summary>
 /// <param name="objectToDespawn">Object to despawn.</param>
 public void Despawn(PoolableObject objectToDespawn)
 {
     if (objectToDespawn != null)
     {
         if (objectToDespawn.OriginObjectPool == poolId)
         {
             if (showDebugInfo)
             {
                 Debug.Log("Despawning [" + objectToDespawn.CachedGameObject.name + "] from pool [" + objectToDespawn.OriginObjectPool);
             }
             objectToDespawn.OnDespawn();
             objectToDespawn.CachedTransform.SetParent(ServiceLocator.Instance.GetServiceOfType <BasePoolManager>(SERVICE_TYPE.POOLMANAGER).transform);
             spawnedPoolableObjectsList.Remove(objectToDespawn);
             if (!despawnedPoolableObjectsList.Contains(objectToDespawn))
             {
                 despawnedPoolableObjectsList.Add(objectToDespawn);
             }
             else
             {
                 if (showDebugInfo)
                 {
                     Debug.Log("Already Despawned");
                 }
             }
         }
     }
 }