stop a coroutine unity code example
Example 1: stop specific coroutine unity
Coroutine co;
// start the coroutine the usual way but store the Coroutine object that StartCoroutine returns.
co = StartCoroutine(MyCoroutine());
// stop the coroutine
StopCoroutine(co);
Example 2: unity stop all coroutines
//Stop all coroutines
StopAllCoroutines();