Example #1
0
        /// <summary>
        /// 2017-8-4
        ///
        /// PoolSize limits the maximum number of items in the pool for the provided prefab.
        /// If the limit provided is UNLIMITED (-1), then the pool has no limit.
        ///
        /// StaleDuration limits the maximum time an object is maintained when not in use. Object that
        /// are not used within this duration are Destroyed.
        ///
        /// Side effects:
        ///     When an object pool does not exist for the prefab parameter, one is created automatically.
        /// </summary>
        public static void SetLimit <T>(int?poolSize = UNLIMITED, float?staleDuration = UNLIMITED) where T : new()
        {
            IPool pool = GetPool <T>();

            if (poolSize != null)
            {
                pool.MaxSize((int)poolSize);
            }
            if (staleDuration != null)
            {
                pool.StaleDuration((int)staleDuration);
            }
        }
Example #2
0
        /// <summary>
        /// 2017-8-4
        ///
        /// PoolSize limits the maximum number of items in the pool for the provided prefab.
        /// If the limit provided is UNLIMITED (-1), then the pool has no limit.
        ///
        /// StaleDuration limits the maximum time an object is maintained when not in use. Object that
        /// are not used within this duration are Destroyed.
        ///
        /// Side effects:
        ///     When an object pool does not exist for the prefab parameter, one is created automatically.
        /// </summary>
        public static void SetLimit(GameObject prefab, int?poolSize = UNLIMITED, float?staleDuration = UNLIMITED)
        {
            IPool pool = GetPool(prefab);

            if (poolSize != null)
            {
                pool.MaxSize((int)poolSize);
            }
            if (staleDuration != null)
            {
                pool.StaleDuration((int)staleDuration);
            }
        }