- Home /
Monodevelop Debugger evaluates temp variable as "null" in for loop when clearly not null
Whenever I'm using Monodevelop-Unity to step through code in a for..in
loop (aka "foreach"), if I try to add the temporary variable to the watchlist, it always evaluates to null
, even when the value is clearly not null
(and the code executes to represent this).
For example:
for (var firingShip : GameObject in firingFleetArray) {
if (firingShip) {
firingShip.GetComponent(Ship).Fire();
}
}
If I add firingShip
to the Watch list, it always displays as null
. But at the same time if I add firingFleetArray
to the Watch list it will display its members correctly (none of which are null
). Additionally, I can Step Into the code and get to the Fire()
function, even though the code should skip over it if firingShip
were actually null
.
I've googled everywhere for something like this but can't find anything. Is something messed-up about my installation, or am I missing some obvious setting?
Only if there's something messed up about $$anonymous$$e too :/ $$anonymous$$onoDevelop debugging is very flaky around variable evaluation I find. Hoping someone else knows more than I do about it.
And while we're at it - how can we be 2 versions behind the current on $$anonymous$$onoDevelop - 3.x added amazingly improved refactoring and usage searching.
Apparently so. I think it probably depends on how you script, but there are big holes in it for sure.
Answer by ProgrammerJoe · Sep 08, 2013 at 10:43 PM
This can happen if the variable you are watching is an object derived from UnityObject. If the "name" field isn't set it will be null, and UnitObject's ToString method will unhelpfully return that as the value of the variable.
This also seems to cause MonoDevelop to get confused about the fact that the variable has a real value in some cases. I fixed it in my case by not having a couple of classes derive from UnityObject.
Your answer
Follow this Question
Related Questions
Any way to see if a gameObject has a component from MonoDevelop debugger? 0 Answers
Monodevelop attach Android player to process 1 Answer
How to access static members in the watch/immediate window when debugging with MonoDevelop 0 Answers
Stepping in MonoDevelop Debugger takes a long time when using buttons 1 Answer