Page 2 of 2
Re: Interacting with Response using keyboard/controller
Posted: Sat Sep 26, 2015 12:48 pm
by alfonso
You can changed this behaviour in the EventSystem gameObject of the scene, there in the Standalone Input Module, you can change the axis(Horizontal, Vertical) Cancel and submit buttons. And in the input setting (edit->project settings -> input) you can change how unity recognize the axis and the cancel submit buttons.
i think unity assign automatically the stick to the same of this axis
Re: Interacting with Response using keyboard/controller
Posted: Sat Sep 26, 2015 3:44 pm
by nishant
Just an update .. I managed to fix it . About the auto focus not working , it was my bad
. Just that the highlight color was same as normal color ,so although it was getting focus , it wasn't visible. About the navigation not working , that was because my game uses a custom input module which overrides the default one . So for that I made another script that would manually switch the buttons based on the key . I took reference of the code that Alfonso sent before.
Code: Select all
if(UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject == this.gameObject)
{
if (Input.GetKeyDown(keySelect) || (!string.IsNullOrEmpty(buttonNameSelect) && Input.GetButtonDown(buttonNameSelect))) {
var pointer = new PointerEventData(EventSystem.current);
ExecuteEvents.Execute(button.gameObject, pointer, ExecuteEvents.submitHandler);
}
//HACK
if (Input.GetKeyDown(keyUp) || (!string.IsNullOrEmpty(buttonNameUp) && Input.GetButtonDown(buttonNameUp))) {
StartCoroutine(SetSelectedGameObject(nav.selectOnUp.gameObject));
}
if (Input.GetKeyDown(keyDown) || (!string.IsNullOrEmpty(buttonNameDown) && Input.GetButtonDown(buttonNameDown))) {
StartCoroutine(SetSelectedGameObject(nav.selectOnDown.gameObject));
}
}
Yes I know , its hacky but will have to do for now till I modify the input module .
Any way thanks guys for your help .