/// <summary> /// List-managed pool container. /// </summary> /// <param name="prefab">The Prefab asociated to the IndexedPoolList</param> /// <param name="size">The starting size of the list</param> /// <param name="limit">The limit for instance creation. Negative values set no limit.</param> public IndexedPoolList(GameObject prefab, int size, int limit = -1) { this.prefab = prefab; this.limit = limit; if (limit >= 0) { size = Mathf.Max(Mathf.Min(size, limit), 0); } objectList = new List <IPoolable>(size); for (int i = 0; i < size; ++i) { GameObject obj = Instantiate(prefab); obj.name = "Pool " + obj.name + " " + i; IPoolable poolObj = obj.GetComponent <IPoolable>(); objectList.Add(poolObj); poolObj.InPool = true; poolObj.Clear(); } }