Пример #1
0
        /// <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);
            }
        }
Пример #2
0
 /// <summary>
 /// Performs pooled instantiation on a specific prefab, and returns requested T MonoBehaviour from it
 /// </summary>
 /// <param name="prefab">GameObject prefab</param>
 /// <returns>Instantiated object</returns>
 public static T Pool <T>(this GameObject prefab) where T : MonoBehaviour, IGenericPoolElement
 {
     return(GenericPooler.InstantiateFromPool <T>(prefab));
 }
Пример #3
0
 /// <summary>
 /// Sets this generic pooler to be used for extension calls
 /// </summary>
 /// <param name="pooler"></param>
 public static void UseForExtensions(this GenericPooler pooler)
 {
     _genericPooler = pooler;
 }
Пример #4
0
 /// <summary>
 /// Prewarms specific prefab, sustaining specific object count for GenericPooler
 /// This operation is costly
 /// </summary>
 /// <param name="prefab"></param>
 /// <param name="objCount"></param>
 /// <param name="preWarmPos"></param>
 public static void SustainPool(this GameObject prefab, int objCount, Vector3 preWarmPos)
 {
     GenericPooler.SustainPool(prefab, objCount, preWarmPos, false);
 }