public void ClearPool(PoolInstanceView poolInstanceView) { int poolKey = poolInstanceView.gameObject.GetInstanceID(); if (pools.ContainsKey(poolKey)) { pools[poolKey].Clear(); } }
public PoolInstanceView ReusePoolInstance(PoolInstanceView poolInstanceView, Vector3 position, Quaternion rotation) { int poolKey = poolInstanceView.gameObject.GetInstanceID(); if (pools.ContainsKey(poolKey)) { return(pools[poolKey].ReusePoolInstance(position, rotation)); } Debug.LogError("Cannot reuse non-existant pool instance"); return(null); }
public PoolInstanceView ReusePoolInstance(Vector3 position, Quaternion rotation) { PoolInstanceView poolInstanceView = Dequeue(); poolInstanceView.Position = position; poolInstanceView.Rotation = rotation; poolInstanceView.gameObject.SetActive(true); poolInstanceView.OnPoolInstanceReuse(); Enqueue(poolInstanceView); return(poolInstanceView); }
public void Initialize() { GameObject prefab = poolRequest.poolInstanceView.gameObject; poolInstanceViews = new Queue <PoolInstanceView>(); poolView.Name = prefab.name + " pool"; poolView.Parent = objectPoolView.transform; for (int i = 0; i < poolRequest.poolSize; ++i) { PoolInstanceView poolInstanceView = container.InstantiatePrefab(prefab).GetComponent <PoolInstanceView>(); poolInstanceView.Parent = poolView.transform; poolInstanceView.gameObject.SetActive(false); Enqueue(poolInstanceView); } }
public void Enqueue(PoolInstanceView poolInstanceView) { poolInstanceViews.Enqueue(poolInstanceView); }