public GameObject GetObjectFromPool(string poolName) { GameObject gameObject = null; if (this.poolDictionary.ContainsKey(poolName)) { Pool pool = this.poolDictionary[poolName]; gameObject = pool.NextAvailableObject(); if (gameObject == null) { Debug.LogWarning("No object available in pool. Consider setting fixedSize to false.: " + poolName); } } else { Debug.LogError("Invalid pool name specified: " + poolName); } return(gameObject); }
/* Returns an available object from the pool * OR * null in case the pool does not have any object available & can grow size is false. */ public GameObject GetObjectFromPool(string poolName, Vector3 position, Quaternion rotation) { GameObject result = null; if (poolDictionary.ContainsKey(poolName)) { Pool pool = poolDictionary[poolName]; result = pool.NextAvailableObject(position, rotation, transform); //scenario when no available object is found in pool if (result == null) { Debug.LogWarning("No object available in pool. Consider setting fixedSize to false.: " + poolName); } } else { Debug.LogError("Invalid pool name specified: " + poolName); } return(result); }