public void ReturnObjectToPool(GameObject objectToReturn) { // do we have an actual gameobject if (objectToReturn == null) { Debug.LogError("Attempted to return null object to pool, this is not allowed!"); return; } // and is it a pooled/able object PoolObject poolObject = objectToReturn.GetComponent <PoolObject>(); if (poolObject == null) { Debug.LogError("Attempted to return object that isn't from a pool, this is not allowed!"); return; } //return to the dictionary of pools poolDictionary[poolObject.poolKey].Add(poolObject); // parent to this for storage in hierachy poolObject.transform.SetParent(transform); //disable the object poolObject.DisablePoolObject(); }
/// <summary> /// Instantiates a new PoolAsteroid and add to list. /// </summary> /// <param name="poolAsteroidToSpawn">Asteroid to instnatiate</param> /// <param name="poolListToAdd">List to add</param> private void InstantiateNewPoolObject(PoolObject poolAsteroidToSpawn, List <PoolObject> poolListToAdd) { Vector3 pos = Vector3.zero; pos.z = -1; PoolObject newPoolObject = (PoolObject)Instantiate(poolAsteroidToSpawn, pos, Quaternion.identity); newPoolObject.DisablePoolObject(); //Add to pool list poolListToAdd.Add(newPoolObject); }
private PoolObject InstantiateNewPoolObject(PoolObject poolObjectToSpawn, List <PoolObject> poolListToAdd) { //New poolObject PoolObject newPoolObject = (PoolObject)Instantiate(poolObjectToSpawn, Vector3.zero, Quaternion.identity); // start disabled newPoolObject.DisablePoolObject(); //use this as the transform to keep pool objects organised. newPoolObject.transform.SetParent(transform); //make sure there is a pool object script on the new object newPoolObject.gameObject.AddComponent <PoolObject>(); //Add to the pool list poolListToAdd.Add(newPoolObject); return(newPoolObject); }
public void DisabledObject() { myPoolObject.DisablePoolObject(); }
public void DisabledObject() { ActiveEffect(); myPoolObject.DisablePoolObject(); }