When you start a coroutine, you have the option of supplying a tag. A tag is a string that identifies that coroutine. When you tag a coroutine or a group of coroutines you can later kill that coroutine or that group using KillCoroutine(tag) or KillAllCoroutines(tag).
void Start ()
{
Timing.RunCoroutine(_shout(1, "Hello"), "shout");
Timing.RunCoroutine(_shout(2, "World!"), "shout");
Timing.RunCoroutine(_shout(3, "I"), "shout2");
Timing.RunCoroutine(_shout(4, "Like"), "shout2");
Timing.RunCoroutine(_shout(5, "Cake!"), "shout2");
Timing.RunCoroutine(_shout(6, "Bake"), "shout3");
Timing.RunCoroutine(_shout(7, "Me"), "shout3");
Timing.RunCoroutine(_shout(8, "Cake!"), "shout3");
Debug.Log("Killed " + Timing.KillCoroutines("shout2"));
}
IEnumerator _shout(float time, string text)
{
yield return Timing.WaitForSeconds(time);
Debug.Log(text);
}
// Output:
// Killed 3
// Hello
// World!
// Bake
// Me
// Cake!
