IEnumerator SpawnRoutine() { yield return(new WaitForSeconds(startDelay)); //keep on looping while (true) { Collectible newObj = SpawnItem(spawnArea.GetPosition()); if (newObj != null) { newObj.SetTriggerCallback(this.ItemTriggeredCallback); //set callback function for the collectible (which clear the item in existingItemList) existingItemList.Add(newObj); //add the new item to existingItemList } //wait for spawnCD before attempting next spawn yield return(new WaitForSeconds(spawnCD)); } }