Example #1
0
 //o(1)
 public void ReturnObjectToPool(PoolObject poolObject_)
 {
     if (_poolObjectType.Equals(poolObject_._poolObjectType))
     {
         if (poolObject_._isPooled)
         {
             Debug.LogWarning(poolObject_.gameObject.name + " is already in pool. Why are you trying to return it again? Check usage.");
         }
         else
         {
             AddObjectToPool(poolObject_);
         }
     }
     else
     {
         Debug.LogError(string.Format("Trying to add object to incorrect pool {0} {1}", poolObject_._poolObjectType, _poolObjectType));
     }
 }
Example #2
0
        public PoolObject GetObjectFromPool(PoolObjectType poolObjectType_, Vector3 position_, Quaternion rotation_)
        {
            PoolObject result = null;

            if (_poolDictionary.ContainsKey(poolObjectType_))
            {
                Pool pool = _poolDictionary[poolObjectType_];
                result = pool.NextAvailableObject(position_, rotation_, PoolManager._instance.transform);
                if (result == null)
                {
                    Debug.LogWarning("No object available in pool. Consider setting fixedSize to false.: " + poolObjectType_);
                }
            }
            else
            {
                Debug.LogError("Invalid pool name specified: " + poolObjectType_);
            }

            return(result);
        }
Example #3
0
 public void ReturnObjectToPool(PoolObject poolObject_, bool reParent_ = false)
 {
     if (poolObject_ == null)
     {
         Debug.LogWarning("Specified object is not a pooled _instance: " + poolObject_.name);
     }
     else
     {
         if (_poolDictionary.ContainsKey(poolObject_._poolObjectType))
         {
             Pool pool = _poolDictionary[poolObject_._poolObjectType];
             if (reParent_)
             {
                 poolObject_.transform.parent = PoolManager._instance.transform;
             }
             pool.ReturnObjectToPool(poolObject_);
         }
         else
         {
             Debug.LogWarning("No pool available with name: " + poolObject_._poolObjectType);
         }
     }
 }
Example #4
0
 public void ReturnObjectToPool(PoolObject poolObject_, bool reParent_ = false)
 {
     poolObject_._poolObjectType._objectPool.ReturnObjectToPool(poolObject_, reParent_);
 }