handzlikchris / Unity.MissingUnityEvents

Editor extension to generate events that are executed before property set, eg. Transform-position, Transform-rotation, Transform-parent which allows to write more event driven code or debug property changes that are not simple to track down. Easily customisable to allow adding events to different property setters / types.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Events are not triggered when using undo in the editor.

NeistH2o opened this issue Β· comments

commented

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 πŸ€”

commented

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.