- Home /
Change navigation keys for UI at runtime
How do you change which gamepad buttons and axis or keyboard keys are used for navigating the UI system added in 4.6 at runtime?
Comment
Best Answer
Answer by Kody · May 05, 2015 at 05:56 AM
Figured it out. I can create a custom EventSystem with the "StandaloneInputModule" script disabled then make my own script that is something like:
void Update()
{
timer -= Time.deltaTime;
if(timer > .0f)
return;
AxisEventData ad = new AxisEventData(EventSystem.current);
if(Controls.Up())
ad.moveDir = MoveDirection.Up;
else if(Controls.Down())
ad.moveDir = MoveDirection.Down;
else if(Controls.Left())
ad.moveDir = MoveDirection.Left;
else if(Controls.Right())
ad.moveDir = MoveDirection.Right;
else
return;
ExecuteEvents.Execute(EventSystem.current.currentSelectedGameObject, ad, ExecuteEvents.moveHandler);
timer = cooldown;
}
To send events to the UI system without using the standard inputs.
Your answer
Follow this Question
Related Questions
Accessing Standalone Input Module Data 0 Answers
Detect if mouse if hovering over UI element to change behavior of mouse wheel input 1 Answer
InputField null refrence exception 1 Answer
A game entirely made with the new UI ? 1 Answer
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers