In the last section of the Realm Rush course of the Object Pool tutorial, I used a foreach loop instead of the recommended for loop.
I just wanted to check if someone could tell me if this is correct?
Thanks!
IEnumerator SpawnEnemy()
{
while(true)
{
EnableObjectInPool();
yield return new WaitForSeconds(spawnTimer);
}
}
void EnableObjectInPool()
{
foreach (GameObject objectInPool in pool)
{
if(!objectInPool.activeInHierarchy)
{
objectInPool.SetActive(true);
return;
}
}