Well coroutines are not the easy way for one shots…People use coroutines so wrong. You fire up a coroutine its gonna sit there and wait till you let it do its function again.
While you can stop a coroutine, they don’t interact with unity objects, in fact you will make a mess of things. Coroutines in unity are best used to run something routine and regular while letting your normal game loop continue on its merry way instead of waiting for example a long for loop to finish. They are designed to be a copilot, not a fire and forget. If you insist on a fire and forget outside the main thread, then threading would probably be a better solution, just make a new thread, do your thing, then join back in.
Coroutines are powerful, when used right, you can set them up to be a parallel process and help handle heavy loads while letting your game smoothly truck along. However you need to be careful using them, they are NOT thread safe, they are NOT even threaded (unless you make them that way), it is really advanced coding. I encourage people to learn them and play with them, but for mercy sake please don’t use them in a product you release until you really know what you are doing with them.
A better coding practice for what you are describing would be to think logically through the entire situation. Wait timers aren’t so good in your main loop. However setting a variable to the current time then checking it on each update or fixed update for a difference to match a total time works good. (You start a timer, you hang your loop, unless the timer is threaded).
Example
private float startWatch;
start() {
startWatch = Time.time;
}
Update() {
if(Time.time - startWatch >= yourFloatTimeToWait) {
do something;
}
}
Ok terrible code I know but I think it gets the point across. No hiccups for your game loop, timer will fire your something when its delay has passed.
Also why are you delaying, usually there is something that you are waiting for, and that is why you need to wait, generally you can hook into that something and check is it alive, is it true, call your function on that objects awake. Just because threadrippers are out with 32 cores on desktops doesn’t mean you should hammer them 