- Home /
Override Editor Controls
Hi all, I've been wondering about this for a few days now, and gave up on it after not finding any answers after a fair whack of searching and just used different key controls. Essentially I have a level editor 'editor script' which allows me to grab objects, group grab, move, spawn and locks the object positions to a grid all on a very basic level which has been very useful in saving some time. Now I've been detecting input commands from the user with the Event class, along the lines of:
if( Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.R )
Which works fine, however I would really like to make it so that I can left click to select objects, or place them and press Spacebar to toggle my editor modes.
Unfortunately left click selects a scene object and Spacebar maximises the current windows viewport. What I would to do is override these controls, so that when my custom inspector (which is my level editor script) is active, it does what I define in that script, is there a way to do this?
Unity obviously has this behaviour as if you edit a terrain, your left clicks don't select the terrain or other objects, they paint textures and such. I'm just not sure if it's exposed - would kinda suck for editor scripting if not though surely?
Anyone ever find a solution to achieve this functionality? I am interested in doing the same. For example, when a user presses delete while my level editor is being used, I do not want the default behavior of the Unity editor to be used.
Answer by Wenceslao · Sep 20, 2012 at 07:44 AM
I'm trying to do something very similar by creating an editor script that allows me to do something like Shift + Left Click on the scene to add waypoints but unfortunately this works the first time but then shift left click selects another object which changes the currently selected object. After a lot of searching I gave up as well and just went with a key combination to drop it at the mouse position.
Your answer
Follow this Question
Related Questions
[Editor] Get Scroll Wheel while dragging 0 Answers
TextField, Event.current, Input.GetKey, and GUI.FocusControl locking 1 Answer
Unity UI 4.6 - Programmatically adding events - EventTrigger.delegates is null 0 Answers
Editor Scripting - Override Scaling 1 Answer
Detect when project is saved 1 Answer