title: Cancelling Coroutine when Home button presseddown or returned main menu
body: <p>some pretext of what I am doing ; I am currently locking down my skill buttons via setting interactable = false in coroutines. Showing text of remaning seconds via textmeshpro and setting them deactive when countdown is over. But I am having problem when home button is pressed/ returned main menu. I would like to refresh my buttons cooldowns and stop coroutines when its pressed. But it is staying in lock position.</p>
  
  <p>this is my cooldown coroutine</p>
  
  <pre><code>static List&lt;CancellationToken&gt; cancelTokens = new List&lt;CancellationToken&gt;();
  
  ...
  
  public IEnumerator StartCountdown(float countdownValue, CancellationToken cancellationToken)
      {
          try
          {
              this.currentCooldownDuration = countdownValue;
              // Deactivate myButton
              this.myButton.interactable = false;
              //activate text to show remaining cooldown seconds
              this.m_Text.SetActive(true);
              while (this.currentCooldownDuration &gt; 0 &amp;&amp; !cancellationToken.IsCancellationRequested)
              {
  
                  this.m_Text.GetComponent&lt;TMPro.TextMeshProUGUI&gt;().text = this.currentCooldownDuration.ToString(); //Showing the Score on the Canvas
                  yield return new WaitForSeconds(1.0f);
                  this.currentCooldownDuration--;
  
              }
          }
          finally
          {
              // deactivate text and Reactivate myButton
              // deactivate text
              this.m_Text.SetActive(false);
              // Reactivate myButton
              this.myButton.interactable = true;
          }
  
      }
  </code></pre>
  
  <pre><code>static public void cancelAllCoroutines()
     {
         Debug.Log("cancelling all coroutines with total of : " + cancelTokens.Count);
         foreach (CancellationToken ca in cancelTokens)
         {
             ca.IsCancellationRequested = true;
         }
     }
  </code></pre>
  
  <pre><code>
  
  void OnButtonClick()
      {
  
      CancellationToken cancelToken = new CancellationToken();
          cancelTokens.Add(cancelToken);
  
          Coroutine co;
          co = StartCoroutine(StartCountdown(cooldownDuration, cancelToken));
          myCoroutines.Add(co);
  
      }
  </code></pre>
  
  <p>this is where I catch when home button pressed/returned main menu. when catch it and pop pauseMenu</p>
  
  <pre><code>public void PauseGame()
      {
          GameObject menu = Instantiate(PauseMenu);
          menu.transform.SetParent(Canvas.transform, false);
          gameManager.PauseGame();
          EventManager.StartListening("ReturnMainMenu", (e) =&gt;
          {
              Cooldown.cancelAllCoroutines();
              Destroy(menu);
              BackToMainMenu();
              EventManager.StopListening("ReturnMainMenu");
          });
          ...
  </code></pre>
  
  <p>I also stop time when game on the pause</p>
  
  <pre><code>public void PauseGame() {
          Time.timeScale = 0.0001f;
      }
  </code></pre>