Are there any plans to develop tools or expose APIs for monitoring variable changes? While we can currently track changes in our own variables, it would be pretty handy to have the ability to track changes in Unity variables, complete with a stack trace and graphs. For example, when dealing with a Transform that is changed from various sources, it's really hard to track why the object is moving/rotating/scaling. This tool could also be applied to other variables such as animator variables, layers, rigidbody properties, and others.
It could be editor only since it would have big overhead, but really useful.
#Tool for tracking variable changes
1 messages · Page 1 of 1 (latest)
There are some attempts at that, but in my experience they are all iffy since they don't have good interface to underlying objects and have to hack their way through.
or, if you cannot talk about future plans, any idea how to tackle this problem?
We do have some tools for this. You can hook into the Undo system to see changes https://docs.unity3d.com/ScriptReference/Undo-postprocessModifications.html
You can also use change events https://docs.unity3d.com/ScriptReference/ObjectChangeEvents.html
that does sound promising, thank you for the resources
I'll look into it, but if you know on top of your head
can I get stack trace from it?
Yes you should be able to. It may contain some native calls.
thanks :)
I just tested this, it works when you modify a property in editor.
but if the property is changed from the code, the event doesn't fire.
I think I cannot use undo system as a solution to this problem
Theres no way for us to know if you change a property by script without using the undo system.