Timeline for Wait until continuing inside a function with a coroutine in Unity
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 12, 2017 at 23:55 | vote | accept | user441521 | ||
Oct 12, 2017 at 23:49 | answer | added | DMGregory♦ | timeline score: 2 | |
Oct 12, 2017 at 23:43 | comment | added | user441521 | Is there a way to do this without StartCoroutine()? Like when using WaitForSeconds() it's yield return new WaitForSeconds(). it doesn't use StartCoroutine() in the way I'm using it. | |
Oct 12, 2017 at 23:24 | comment | added | DMGregory♦ |
If you don't use yield then you're making an explicit statement "DO NOT wait for this IEnumerator/coroutine to finish before proceeding." If that's not what you mean, then you need to tell the compiler what you want it to do instead.
|
|
Oct 12, 2017 at 22:43 | comment | added | user441521 | It's no more lines but I find the implied yield is cleaner and less typing. JumpToTarget(target) is much cleaner than yeild return StartCoroutine(JumpToTarget(target)); even if it loses some meaning. I know the meaning as everything in Do() is sequential in nature. So basically there is no way around this? | |
Oct 12, 2017 at 22:40 | comment | added | DMGregory♦ |
Execution runs until it hits a return , yield , await , or the end of the method (or an Exception is thrown...). So if you want execution to pause somewhere mid-stream, you have to tell it so using the yield or await keywords. Why is it that you don't want to put a yield inside Do() ? It's no more lines than you have now, and it's more explicit about the desired behaviour, so it seems like a win-win.
|
|
Oct 12, 2017 at 22:17 | history | asked | user441521 | CC BY-SA 3.0 |