I want to get KeyCodes by user input using Event.current (writing in C#).
I have accomplished what I want for the most part by doing this:
-checking the EventType of Event.current
–for EventType.KeyDown, getting the KeyCode by keyCode directly
–for EventType.MouseDown, getting the button id and determining the KeyCode.
This is working, but I am struggling to read any input from custom/additional mouse buttons (i.e. forward/back buttons on the mouse, or mouse button ids that should be >2).
How can I read these additional mouse buttons via Event.current (or any other way) ?
To make this more clear: when Event.current.isMouse == true, Event.current.button will only return 0,1, or 2 (left, right, or middle click). It never recognizes a Mouse3 or 4 button.
In general, the code actually only supports 3 buttons. The code here is platform-dependent so could be there’s some platform that actually does go beyond three buttons but at least on Windows, only the left, right, and middle mouse button are handled.
Ok thanks for the info; so basically Event seems limited in this situation.
I’ve worked around my problem for now by checking Input.GetKeyDown for Mouse3-6 from an Update function; if anyone has other ideas that wouldn’t require the Update function let me know, but this works for now.
This is a pretty strange limitation considering Input.GetKey seems to work with up to 6 mouse buttons at runtime and has to support way more platforms (havent checked if it works on consoles and mobile ;))
As far as I know the editor is limited to Windows, Mac and Linux.
Besides the Input.GetKey works in playmode in the editor. So there has to be a way to get them in an editor window!?
For now I will try to work around it with user32.dll:
[DllImport("user32.dll")]
public static extern Int16 GetAsyncKeyState(Int32 virtualKeyCode);
Btw. it would be great to add mouse support to the shortcut manager.