IEnumerator not found error

While everything was going well, I encountered this error and I’ve been trying to figure out how to fix it for a long time.

using UnityEngine;

public class Spawner : MonoBehaviour
{

    public Birdy BirdScript;
    
    public GameObject Borular;
   
    public float height;

    public IEnumerator SpawnObject()
    {

     while (!BirdScript.isDead)
     {

        Instantiate(Borular, new Vector3(3, Random.Range(-height, heigh),0), Quaternion.identity);
    
        yield return new WaitForSeconds(1f);
     }

    
    }
            
}

Put using System.Collections; at the top of the script. Some types live in specific namespaces and those need to be included.

Why Unity removed the default namespaces from monobehaviour scripts is beyond me.

1 Like

This code was not there when I opened Visual Studio before. I added it now. thanks