public ObjectPoolItem CreateItemToPool(GameObject type) { ObjectPoolItem thisPoolItem = new ObjectPoolItem(Instantiate(type)); ObjectPoolReference thisPoolReference = thisPoolItem.itemInstance.GetComponent <ObjectPoolReference>(); if (thisPoolReference != null) { thisPoolReference.objectPool = this; thisPoolReference.objectType = type; } AddItemToPool(type, thisPoolItem); return(thisPoolItem); }
void OnTriggerEnter(Collider col) { Coin coin = col.GetComponent <Coin>(); if (coin != null) { ChangeHealth(coin.CoinDamage); ObjectPoolReference opf = col.GetComponent <ObjectPoolReference>(); if (opf != null) { opf.returnToPool(); } else { Destroy(coin.gameObject); } } }