Hi, I’ve been working on trying to implement controller support for navigating the UI as well, but noticed that not much is possible or implemented yet. To make controllers work well with UGUI we had to override the evensystem and create our own buttons to make sure nothing goes wrong (such as buttons deselecting). Are there currently any plans on how Unity wishes to implement controller support for UI Toolkit in the future?, Here are a few controller support use case examples:
- Navigating through the UI with a controller and simulating the press of a UI Button when you press on the “submit” button on your controller. Currently it is doable, but requires extra work as uBenoitA has stated. I’ve tried doing this myself in a test project and it isn’t very pretty currently.
The code below shows the test I’ve made. I’m not sure if calling “Focus()” is necessary. The idea was to simulate the mouse hovering over the button when pressing “F” and the mouse clicking when pressing “G”.
private void Update()
{
if (Input.GetKeyDown(KeyCode.F))
{
pushSecondViewButton.Focus();
MouseEnterEvent mouseOver = MouseEnterEvent.GetPooled();
mouseOver.target = pushSecondViewButton;
pushSecondViewButton.SendEvent(mouseOver);
}
if (Input.GetKeyDown(KeyCode.G))
{
MouseDownEvent mouseDown = MouseDownEvent.GetPooled();
mouseDown.target = pushSecondViewButton;
pushSecondViewButton.SendEvent(mouseDown);
NavigationSubmitEvent submit = NavigationSubmitEvent.GetPooled();
submit.target = pushSecondViewButton;
pushSecondViewButton.SendEvent(submit);
}
}
-
A problem that I’m having with the current UGUI system is that buttons can be deselected and that it breaks all controller navigation. It is also talked about here: Feature request: option to disable deselect in UI Input Module , and I was also wondering if this feature would come to UI Toolkit, and if so in what form?
-
“Pressing” buttons that cannot be navigated to using B/X/Y LB/RB controller buttons. Whilst it may be possible to bind manually through code, it’s really something you’d want to automate because almost every game needs this. In addition, you’d want to make sure the “press” effect would work to be passed through to the visual element to provide visual confirmation of players pressing the buttons.