title: What Is an IEnumerator In C# and what is it used for in Unity?
body: <p>Recently I saw a tutorial of spawning objects using C# in Unity. In that the teacher used a function like this</p>
  <pre><code>   public IEnumerator CallSpawner()
     {
        yield return new WaitForSeconds(0.5f);
        SpawnObstacles();
     }
  </code></pre>
  <p>I wanna ask what is the use of IEnumerator function. Can't we do this by this process</p>
  <pre><code>float diffTime = 0f;
  private void Update()
  {
      if(Time.time - diffTime == 0.5f)
      {
          diffTime = Time.time;
          SpawnObstacles();
      }
  }
  </code></pre>
  <p>I read the <strong>documentation</strong> but couldn't understand it..</p>