- Home /
Capture input events before scene view does?
Hi,
I'm trying to make some extensions to the scene view to implement custom rotation and translation for objects, when there's a specific component present. I created a custom editor for my component and used OnSceneGUI
to capture input events.
When I use a trigger key (T, for example) to enable custom transformation and then just capture MouseMove
events, everything works fine. However, if I try to use MouseDown
, MouseUp
and MouseDrag
instead, the editor always takes the event away from me, i.e, MouseDown
is treated by the editor, which deselects the current object or changes the selection to another object (as expected for scene view) and, as so, my custom editor code never gets the chance to treat MouseDrag
, for the currently selected object is no longer of the custom editor's type. I'm calling Event.current.Use() everytime, to make sure I can steal the event from the editor, however, it doesn't seem to work. Any ideas?
Also, is there any more elegant way to do this? I've spent some time digging inside Unity's assemblies trying to figure out a way to capture Tool's events, like when the user actually uses the gizmos to move, rotate and scale objects, however, after realizing the complexity of the calls I'd have to make using a lot of reflection, I decided for this simpler solution...
Thanks!
Actually, found the answer myself: http://answers.unity3d.com/questions/211034/preventing-editor-deselect-on-macos.html
I had seen the topic, but didn't catch it that it solved my issue then...