/// <summary> /// Returns IGenericPoolElement back to the respective GenericPooler /// </summary> public static void ReturnToPool(this IGenericPoolElement element) { Debug.Assert(element != null, "Element is null"); if (element.UsesAutoPool) { AutoPooler.ReturnToPool(element); } else { GenericPooler.ReturnToPool(element); } }
/// <summary> /// Performs pooled instantiation on a specific prefab, and returns requested T MonoBehaviour from it /// This one passes to AutoPooler instead (which automatically checks if object is .IsAvaiable) /// </summary> /// <param name="prefab">GameObject prefab</param> /// <returns>Instantiated object</returns> public static T AutoPool <T>(this GameObject prefab) where T : MonoBehaviour, IGenericPoolElement { return(AutoPooler.InstantiateFromPool <T>(prefab)); }
/// <summary> /// Sets this auto pooler to be used for extension calls /// </summary> /// <param name="autoPooler"></param> public static void UseForExtensions(this AutoPooler autoPooler) { _autoPooler = autoPooler; }
/// <summary> /// Prewarms specific prefab, sustaining specific object count for AutoPooler /// This operation is costly /// </summary> /// <param name="prefab"></param> /// <param name="objCount"></param> /// <param name="preWarmPos"></param> public static void SustainAutoPool(this GameObject prefab, int objCount, Vector3 preWarmPos) { AutoPooler.SustainPool(prefab, objCount, preWarmPos, true); }