Stop unnamed Coroutine instance

When I start a Coroutine like this


Is there any way to stop it again? And if not, what is the point of the Coroutine-Class?


MyCoroutine has parameters, so it actually looks like this:

StartCoroutine(MyCoroutine(a, b, c));

And I might have multiple instances of the Coroutine running simultaniously.

The only solution I could come up with is to dynamically add empty MonoBehaviors to the GameObject and run each Coroutine in that behavior. But that seems very dirty to me (I did not yet actually try this).

Also I wonder what the point of the Coroutine-Class is.

You can check out the Unity script reference page for StopAllCoroutines() here.

With this approach, just be aware that calling StopAllCoroutines() will stop all coroutines you have running on that behavior, which may lead to undesired results if you have more than one coroutine running. If you want to stop that individual coroutine, then you will need to call and stop it like this:


You can read more about coroutines here.