- Home /
So does StopAllCoroutines also CancelInvoke ?
every great piece of code to blow stuff up, starts with this...
CancelInvoke();
StopAllCoroutines();
but I'm just curious, does anyone know if the latter actually does anyway the former (or indeed, vice versa?)
Thanks!
Another related point to stuff in here: I've always assumed that - this is in Javascript - any routine which uses yield; even once, is then, a coroutine. Is that correct?
But then, if you stick :IEnumerator after the function name, does that force it to be a coroutine? What about if you have the :IEnumerator, but, actually never use yield; in the routine? Again this is U/S
No big deal just curious if anyone happens to know precisely the exact amswer to this. Cheers
Answer by Eric5h5 · Sep 03, 2012 at 04:48 PM
No, StopAllCoroutines won't cancel any Invoked functions, nor will CancelInvoke affect any coroutines. (But come on, it would take you 10 seconds of experimentation to confirm this!)
Unityscript can use type inference for functions as well as variables, so yes, any usage of yield implicitly causes the function to return IEnumerator.
As to whether a function that returns IEnumerator but never actually does any coroutine stuff would be called a coroutine, that's perhaps a matter of semantics, but I would say no: coroutines always return IEnumerator, but it's not true that an IEnumerator always means you're using it in a coroutine.
1 - awesome, thanks!
2 - I know, but it's an opportunity to chat online!
3 - I guess what I meant is .. um .. if you shove :IEnumerator on the end, but do NOT actually mention yield within. Then, will StopAllCoroutines actually, err, stop that routine? I guess this is conceptually daft because it's never "in the middle" of that routine in any sense, nothing is running simultaneously.
I guess what I mean is "In the case described does Unity bother flagging it as a routine that it has to look through for 'yields' even though there are none| ... anyway .. fogget about it :) I've got the idea
3B - your third last word is meant to be "as" not "in" correct.. ..??
thahks again
No, I meant what I said. ;) See here: http://msdn.microsoft.com/en-us/library/system.collections.ienumerator.aspx
Your answer
Follow this Question
Related Questions
Coroutines and states 1 Answer
Are coroutines freezing my game? 0 Answers
How do I properly use Coroutines, yield and animators to sequence commands ? 2 Answers
Inconsistent StopCoroutine behavior with CustomYieldInstruction 1 Answer
Problem with Stopping Nested Coroutines: Control Never Returned to Parent 3 Answers