public int AddObject(GameObject GO, int amt = 3, bool exp = true)
        {
            ObjectPoolItem item    = new ObjectPoolItem(GO, amt, exp);
            int            currLen = itemsToPool.Count;

            itemsToPool.Add(item);
            ObjectPoolItemToPooledObject(currLen);
            return(currLen);
        }
        void ObjectPoolItemToPooledObject(int index)
        {
            ObjectPoolItem item = itemsToPool[index];

            pooledObjects = new List <GameObject>();
            for (int i = 0; i < item.amountToPool; i++)
            {
                GameObject obj = (GameObject)Instantiate(item.objectToPool);
                obj.GetComponent <SoundBlockController>().id       = i;
                obj.GetComponent <SoundBlockController>().playerId = index;
                obj.SetActive(false);
                obj.transform.parent = this.transform;
                pooledObjects.Add(obj);
            }
            pooledObjectsList.Add(pooledObjects);
            positions.Add(0);
        }
Пример #3
0
        void ObjectPoolItemToPooledObject(int index)
        {
            ObjectPoolItem item = itemsToPool[index];

            pooledObjects = new List <GameObject>();
            for (int i = 0; i < item.amountToPool; i++)
            {
                GameObject obj = (GameObject)Instantiate(item.objectToPool);
                // obj.AddComponent<Item>();
                // obj.GetComponent<Item>().initItem(1);
                obj.SetActive(false);
                obj.transform.parent = this.transform;
                pooledObjects.Add(obj);
            }
            pooledObjectsList.Add(pooledObjects);
            positions.Add(0);
        }