Coroutines Flashcards
1
Q
the CPU code of coroutines always appears in two places in a trace.
A
All of the initial code in a coroutine, from the start of the coroutine method until it yields for the first time, appears in the trace wherever the coroutine is started.
All of the rest of a coroutine’s code – from the first time it resumes until it finished executing – appears within the DelayedCallManager line that appears inside Unity’s main loop.
2
Q
Coroutines are backed by an instance of a class that is autogenerated by the C# compiler.
A
local-scope variables are hoisted into the generated class and therefore remain allocated on the heap for the duration of the coroutine.