- Home /
Returning mouse scroll as a keycode
Is there a way to return mouse scroll as a keycode? I've searched unity's documentation but there doesn't seem to be a keycode for mouse scrolling.
Answer by Glurth · Oct 11, 2019 at 07:13 PM
I don't know the details of the use, so I may be off base here., but I think you may be approaching it backwards, given the tools unity has built-in.
Rather than use a keycode to detect the scroll, use an "Axis", from Input. Then in your project settings, you can configure which keys and which other input devices (like mouse scroll wheel) should be mapped to each "Axis".
The main advantage to this is that it takes the "hard-coded" keys (I suspect you use now), and makes them configurable, while keeping your own logic simple.
I understand that unity has their own input system with axes, and they are indeed powerful and simple to use. Except that they can't be bound during runtime and that I intend to do key bindings in my game.
So far the only viable method is to find out which key has been pressed, and change the keycode to a new keycode, and that has been easily done. The only thing that is missing, quite frustratingly, is the ability to assign a bind for mouse scroll.
I apologize that I didn't state my intention for this question, but thank you for replying!