title: Unity: ArgumentException: Value does not fall within the expected range
body: <p>I have met a strange problem when using Coroutine in Unity. Before modification, my code is as the following:</p>
  
  <pre><code>IEnumerator Destory()
  {
      yield return new WaitForSeconds(destoryDelay);
      yield return StartCoroutine(Timer.Start(0.5f, false, gameManager.EnableBtnSummon));
      GameObject.Destroy(this.gameObject);
  }
  </code></pre>
  
  <p><code>Time.Start()</code> is an utility written by myself and used for delay invoke.</p>
  
  <pre><code>public static IEnumerator Start(float duration, bool repeat, Action callback)
  {
      do
      {
          yield return new WaitForSeconds(duration);                
          if (callback != null)
              callback();
      } while (repeat);
  }
  </code></pre>
  
  <p>Because <code>Time.Start()</code> includes <code>WaitForSeconds()</code>, so I decided to modify above code as the following:</p>
  
  <pre><code>IEnumerator Destory()
  {
      //yield return new WaitForSeconds(destoryDelay);
      yield return StartCoroutine(Timer.Start(destoryDelay+0.5f, false, gameManager.EnableBtnSummon));
      GameObject.Destroy(this.gameObject);
  }
  </code></pre>
  
  <p>Unfortunately, console throw an error:</p>
  
  <blockquote>
    <p>ArgumentException: Value does not fall within the expected range.</p>
  </blockquote>
  
  <p><code>gameManager.EnableBtnSummon</code> is just an Action processing game logic. After debug, i make sure that error occurred before this function run. But i will show it for more clues.</p>
  
  <pre><code>public void EnableBtnSummon()
  {
      //will not reach this!
      print("Enable Button Summon");
      //if detecting monster, change relative sprite of monster medal
      if (currentMonsterIndex != -1)
      {
          Image captureMonsterSprite = monsterMedalList.transform.GetChild(currentMonsterIndex).GetComponent&lt;Image&gt;();
          captureMonsterSprite.sprite = mosnterExplicitMedalList[currentMonsterIndex];
  
          Image gameOverMonsterSprite = gameOverMonsterList.transform.GetChild(currentMonsterIndex).GetComponent&lt;Image&gt;();
          gameOverMonsterSprite.sprite = mosnterExplicitMedalList[currentMonsterIndex];
  
          currentMonsterIndex = -1;
          captureMonsterCount++;
      }
  
      if (captureMonsterCount == monsterIndexDictionary.Count) return;
  
      var summonAnimator = btnSummon.GetComponent&lt;Animator&gt;();
      summonAnimator.SetBool("isSearch", false);
  
      btnSummon.enabled = true;
      btnExit.enabled = true;
  
      fogParticleSystem.Play();
  }
  </code></pre>
  
  <p>I cannot understand it, could someone tell me what happens? thx...</p>