Hi everyone,
I am trying to make a one button-press menu using a gamepad and I want when the user clicks on a button in the menu, then that button performs its corresponding action and the menu closes down.
If the user then presses the gamepad button then the menu reappears.
What I want is for the last pressed menu item to be highlighted. I have already tried with the eventSystem.lastselectedGameObject. This works as I can realize that the menu item is selected but not highlighted.
Any suggestions?
eventSystem = GameObject.FindGameObjectWithTag("EventSystem").GetComponent<EventSystem>();
selectedButton = eventSystem.currentSelectedGameObject;
eventSystem.SetSelectedGameObject(selectedButton.gameObject, new BaseEventData(eventSystem));
Solved
I replace the above code with the following:
eventSystem = GameObject.FindGameObjectWithTag("EventSystem").GetComponent<EventSystem>();
ExecuteEvents.Execute<ISelectHandler>(eventSystem.currentSelectedGameObject, new BaseEventData(eventSystem), ExecuteEvents.selectHandler);