x


Input in editor scripts

Is it possible to detect user input in an editor script? The Input class isn't working at all. Input.GetKey never returns true, and Input.mousePosition is always zero.

more ▼

asked Apr 14, 2010 at 03:05 AM

Torre gravatar image

Torre
170 6 10 18

The only thing I have seen that adds a hotkey is when you create a menu item. // Add menu named "Do Something" to the main menu // and give it a shortcut (ctrl-o on Windows, cmd-o on OS X). @MenuItem ("GameObject/Do Something %o") static function DoSomething () { Debug.Log ("Perform operation"); } alexnode 0 secs ago

Apr 14, 2010 at 04:00 PM alexnode
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

It is not. The Input class is only running in playmode and runtime. For editor scripting you are limited to what GUI events offer you - meaning you would need your handler to live in either a custom inspector or an editor window.

more ▼

answered May 21, 2010 at 12:34 PM

AngryAnt gravatar image

AngryAnt ♦♦
4.5k 21 27 71

(comments are locked)
10|3000 characters needed characters left

Input does not work, but you can use Event.current.alt, Event.current.control, etc to see if alt or ctrl or any of the modifier keys are pressed.

And you can use Event.current.button to determine which mouse button is pressed!

more ▼

answered Jul 03, 2012 at 08:01 AM

col000r gravatar image

col000r
170 19 16 31

This made life super easy. Thanks!

May 27 at 10:57 AM Bezzy
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5000
x2825
x1620

asked: Apr 14, 2010 at 03:05 AM

Seen: 5406 times

Last Updated: May 27 at 10:57 AM