public GameObject SpawnFromPool(AllPoolTypes type) { GameObject objToSpawn = poolLogic.GetObjectInQueue(type); objToSpawn.SetActive(true); return(objToSpawn); }
public GameObject SpawnFromPool(AllPoolTypes type, Vector3 position, Vector3 rotation) { GameObject objToSpawn = poolLogic.GetObjectInQueue(type); Quaternion qRot = Quaternion.Euler(rotation); objToSpawn.transform.SetPositionAndRotation(position, qRot); objToSpawn.SetActive(true); return(objToSpawn); }
public GameObject GetObjectInQueue(AllPoolTypes type) { if (!poolDictionary.ContainsKey(type)) { Debug.Log("poolDictionary in ObjectPoolLogic doesn't contain any pool of key: " + type.ToString() + ", see AllPoolTypes to see what type that is."); return(null); } // Gets a reference to the obj furthest in the queue, then put it back into the queue. GameObject objFromQueue = poolDictionary[type].Dequeue(); poolDictionary[type].Enqueue(objFromQueue); return(objFromQueue); }