- Home /
Cannot watch local variable value if the function contains a "yield"
When I use the MonoDevelop to debug, the breakpoint set to a function which contains some "yield", I cannot watch local variable value. It always shows "Unknown identifier".
Is this an issue or need I do some settings for watching in this kind of function?
Answer by roamcel · Oct 27, 2011 at 09:33 AM
I reckon there might be cases where the debugger fails to address the local variables. Your best call is to check the stack window in that case, or to actually create a swatch for your intended variable.
So put a breakpoint 'before' the routine call, and witness where it gets undefined, to understand if it's a compiler problem, or a data problem!
It is a compiler problem or more a debugger problem since coroutines are not functions! A coroutine is implemented as an internal class which holds all local variables. The actual code is compiled into the $$anonymous$$oveNext function (IEnumerator interface). $$anonymous$$ost reflectors can't even decompile a generator function back to C# since the compiler does a lot of hacky tricks to implement the coroutine-statemachine. You can view it as IL but it doesn't help to live debug the function.
Your answer
![](https://koobas.hobune.stream/wayback/20220613023001im_/https://answers.unity.com/themes/thub/images/avi.jpg)