/// <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); }
/// <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); }
void Awake() { Pool = null; IndexInPool = -1; }