- Home /
How to override BaseInput for UI?
The comment in BaseInput script says that it's possible to feed fake input into the UI and that's exactly what I want to achieve but there are no examples of such fake input.
Basically I want to trick Standalone Input Module into thinking that I press Horizontal or Vertical axis for UI navigation even though I don't use unity's default input at all (Specifically, I use https://github.com/speps/XInputDotNet for my gamepads).
Quote from BaseInput summary: "Interface to Input.GetAxisRaw. Can be overridden to provide custom input instead of using the Input class." But there are zero hints on how to proceed.
Answer by deltron1830 · Nov 28, 2018 at 01:09 AM
So somewhere do this..
> public MyMenuNavigator _MyMenuNavigator;
>
> EventSystem.current.currentInputModule.inputOverride = _MyMenuNavigator;
I waited one frame before doing it cus otherwise currentInputModule is null.
And override BaseInputClass
> public class MyMenuNavigator : BaseInput
> {
> public override float GetAxisRaw(string axisName)
> {
> // return whatever u want here
>
> return 0f;
> }
>
> public override bool GetButtonDown(string buttonName)
> {
> // return whatever u want here
>
> return false;
> }
>
> // override more methods for mouse and so on.
> }
Also just fyi,, this sucks!! I found for it to work I had to return the same inputs several times in a row for anything to happen. Like pretty much all the new UI stuff, I dont think its worth bothering with
Your answer
Follow this Question
Related Questions
TextMeshPro Dropdown navigation gamepad problem 0 Answers
How can I disable gamepad input, for my UI? 1 Answer
How can I control UI navigations with Release only interaction with new input system ? 0 Answers
Unity Input - Keep button pressed while key is pressed 0 Answers
is it Possible to use navigation on non UI elements? 1 Answer