public static void CreateOnGameObject(GameObject _go, mg_GameObjectPool _managingPool) { Assert.NotNull(_managingPool, "Pooled objects must belong to a pool"); mg_jr_Pooled mg_jr_Pooled2 = _go.AddComponent <mg_jr_Pooled>(); mg_jr_Pooled2.ManagingPool = _managingPool; mg_jr_Pooled2.IntentionallyDestroying = false; }
private void OnDestroy() { foreach (GameObject item in m_collection) { if (item != null) { mg_jr_Pooled component = item.GetComponent <mg_jr_Pooled>(); component.IntentionallyDestroying = true; } } }
public override void Return(GameObject _objectToAddToPool) { Assert.NotNull(_objectToAddToPool, "Can't add null to a pool"); mg_jr_Pooled component = _objectToAddToPool.GetComponent <mg_jr_Pooled>(); Assert.NotNull(component, "Can't add an object to a pool it didn't come from: mg_jr_Pooled component missing"); Assert.AreSame(this, component.ManagingPool, "Can't add an object to a pool it didn't come from: Managing pool is not this pool"); _objectToAddToPool.transform.parent = base.transform; _objectToAddToPool.SetActive(value: false); m_collection.Push(_objectToAddToPool); }
public void ReturnPooledResource(GameObject _instancedResource) { mg_jr_Pooled component = _instancedResource.GetComponent <mg_jr_Pooled>(); if (component != null) { mg_GameObjectPool mg_GameObjectPool2 = null; foreach (mg_GameObjectPool value in m_pooledResources.Values) { if (value == component.ManagingPool) { mg_GameObjectPool2 = value; break; } } Assert.NotNull(mg_GameObjectPool2, "Returning resource to a pool that doesn't exist."); mg_GameObjectPool2.Return(_instancedResource); } else { _instancedResource.transform.parent = null; Object.Destroy(_instancedResource); } }