Search Unity

StopAllCoroutines should clarify that it only works after using "StartCoroutine"

Discussion in 'Documentation' started by Aladine, Apr 14, 2022.

  1. Aladine

    Aladine

    Joined:
    Jul 31, 2013
    Posts:
    195
    Hi,
    I had this issue today where StopCoroutine wasn't stopping my Coroutine, after tons of research, I gave up and decided to use "StopAllCoroutines", to my surprise, that also didn't work. and the reason was because my coroutine wasn't started with:
    Code (CSharp):
    1. StartCoroutine(MyCoroutine);
    Instead, it was a nested coroutine that was started with:
    Code (CSharp):
    1. yield return MyCoroutine();
    And this can't be stopped with neither StopCoroutine nor StopAllCoroutine.

    so I think StopAllCoroutine documentation should be fixed, considering that its description says:
    "Stops all coroutines running on this behaviour."
    When in reality it only stops all coroutine on this behavior that have been started with StartCoroutine.

    Thanks!