Esempio n. 1
0
        /// <summary>
        /// Create a new pool for the model
        /// The model has to be new, its instanceId will
        /// be used to create a dictionary entry
        /// </summary>
        /// <param name="model">the model of the pool</param>
        /// <param name="poolSize">The number of element in the pool</param>
        /// <param name="expandSize">By how many the pool has to increase</param>
        /// <returns>The new pool</returns>
        public UnityPool AddPool(UnityPoolObject model, uint poolSize, uint expandSize = 1)
        {
            UnityPool newPool = InstanciatePool(model, expandSize);

            newPool.SetSize(poolSize);

            _table.Add(model.GetInstanceID(), newPool);

            return(newPool);
        }
Esempio n. 2
0
        /// <summary>
        /// Instanciate a new pool
        /// </summary>
        /// <param name="model">The model of the new pool</param>
        /// <param name="expandSize">By how many the pool has to increase</param>
        /// <returns></returns>
        private UnityPool InstanciatePool(UnityPoolObject model, uint expandSize)
        {
            GameObject poolGameObject = new GameObject();

            poolGameObject.transform.parent = gameObject.transform;
            UnityPool pool = poolGameObject.AddComponent <UnityPool>();

            pool.transform.parent = gameObject.transform;

            pool.Construct(model, expandSize);

            return(pool);
        }
Esempio n. 3
0
 void Awake()
 {
     Pool        = null;
     IndexInPool = -1;
 }