Hi,
I’m not referring to the ‘Watch’ window, but is it possible to set a watchpoint on a variable such that the debugger breaks on it when its value changes?
(The only other IDE I’m familiar with is Xcode, which has this functionality, so apologies if my terminology is incorrect.)
2 Answers
2Yes it is. They are called BreakPoints. Here is a tutorial of how to enable the functionality in Monodevelop for Unity: http://unitygems.com/debugging-game-monodevelop/
In order to get the Watch Window to work properly you need to first attach your Debugger to the Unity Process. Do this by clicking Run > Attach to process > and select your running copy of Unity. When you play your level in Unity it will break at the appropriate break points and watch your variables.
From there you can set Breakpoints and Watch variables in the Watch window. I just accomplished something similar to what you’re wanting but I don’t know that it will completely solve your needs.
What I did was set a Breakpoint in my code after the variable had been changed to what I wanted. Then if you right click on the Breakpoint and open the Breakpoint properties, you can set it break on a condition evaluating to true. Then I set the condition to be “Variable > X”. So for instance my condition was “Test >= 60”. This isn’t the best way but it is a start hopefully.
You can enable the watch window by going to View > Debug Windows > Watch Window or Pressing Ctrl/Cmd D|F.
Once you open that window you can add a new watch and if you have attached it to the Unity process it should autocomplete your variables when you Add a new watch.
External Reference:
http://www.justapixel.co.uk/start-using-monodevelops-debugger-with-unity3d/
Hope this helps!
Thanks Nomabond. Setting a conditional breakpoint can certainly help. But after some more searching it seems monodevelop doesn't have automatic watchpoints. Also, thanks for the link, at the end of that was a link explaining [Tracepoints][1], which are also pretty useful. (They're like Debug.Log, without having put Debug.Logs in your code) [1]: http://t.co/70h4SoRuuY
– JoeW97
Oh, sorry, I misread your question then. I can not help with that unfortunately.
– GameVortex