Is there a way to have a data breakpoint in unity3d?

Hello there!

Very often I face the same problem:
Some script is changing some value (like transform) and it would be great to have a tool to print the stack of the code that make the modification.

In Visual Studio 2013 there is an option to add a “data breakpoint” which will stop the program whenever the given value changes.
Unfortunately, its for C++ only.

Usually I write a wrapper to debuglog whenever the wrapped code is accessed.
However, this solution consumes time

An option that you have is modify the var to a private field and become a property (with get and set). In this way you can use the breakpoint in the set function.

You can right-click a breakpoint and choose Breakpoint Properties to open a dialog where you can set a condition. Some breakpoints should help you to drill down the code that acidentally modifies the properties.

51831-break.png

Related: https://unity3d.com/learn/tutorials/modules/beginner/scripting/monodevelops-debugger

I’ve put together an asset that allows you to capture/debug all thouse changes to transforms.

Watch on Youtube

That’s available on Asset Store.

There’s an open source approach

PS: ressurected old thread as it still comes up in google and I believe it can be helpful to others