Events are not triggered when using undo in the editor.
NeistH2o opened this issue Β· comments
Hey, I needed a transform position event in the editor and it appears that while the position event is triggered when moving my gameobject around (which is really great! π ) undoing that displacement does not trigger the event.
Just wanted to let you know as I find it surprising that the undo does not access the transform position like anything else would π€
The same thing happens when manually editing x, y or z in the transform component inspector.
I think it'll be down to Undo happening on C++ side of things, probably just reverting to previously saved values. If that's the case then even in C# wrapper will unfortunately not be triggered at all (as property is not used at all).
This tool approach won't be able to help with that. If you're really keen I think I've seen somewhere someone using Microsoft Detours that hook/redirect directly to c++ methods. But it's probably an overkill for what you're after.
As for changing in editor you can have a look at UnityEditor.TransformInspector - it uses SerializedProperty to update / change bypassing actual .postion / .localPosition. It should be straight forward to create a Custom Inspector that uses properties so you can catch those changes.