void _release(GameObject obj) { ObjectPoolId id = obj.GetComponent <ObjectPoolId>(); if (id.Free) { return; } //Culling // Trigger culling if the feature is ON and the size of the // overall pool is over the Cull Above threashold. // This is triggered here because Despawn has to occur before // it is worth culling anyway, and it is run fairly often. if (!id.Pool.CullingActive && // Cheap & Singleton. Only trigger once! id.Pool.cullDespawned && // Is the feature even on? Cheap too. (id.Pool.CountTotal > id.Pool.CullAboveCount)) // Criteria met? { id.Pool.CullingActive = true; //StartCoroutine(id.Pool.CullDespawned()); Timing.RunCoroutine(id.Pool.CullDespawned(), Segment.SlowUpdate); } id.Pool.Release(id); }
public void Release(ObjectPoolId obj) { var release = obj.GetComponent <IPoolRelease>(); if (release != null) { release.DeactivateBeforeRelease(); } _inUse.Remove(obj); CountInUse = _inUse.Count; _free.Add(obj); CountFree = _free.Count; obj.transform.SetParent(!InactiveParentGo ? Instance.transform : InactiveParentGo.transform); obj.SetFree(true); obj.gameObject.SetActive(false); }