public JPoolObject GetObjectFromPool(string key) { JPoolObject founded = null; foundedQueue = null; if (!pool.TryGetValue(key, out foundedQueue)) { foundedQueue = new Queue <JPoolObject>(); pool.Add(key, foundedQueue); } if (foundedQueue.Count <= 0) { JPoolData data = GetPoolData(key); founded = Instantiate(data.prefabObject, new Vector3(0, 10000, 0), Quaternion.identity); } else { founded = foundedQueue.Dequeue(); } founded.gameObject.SetActive(true); founded.OnOutFromPool(); return(founded); }
public virtual JPoolObject GetObject <T>() { JPoolObject foundedObject = null; Type type = typeof(T); if (!pool.TryGetValueOne(type, out foundedObject)) { Debug.LogError($"Not foundex {type.ToString()}"); return(null); } foundedObject.OnOutFromPool(); return(foundedObject); }