I'm a dummy, and I'm not sure how to fix this particular problem, but here's the setup.
Project uses Adventure Creator and the new Input System. I've got code that uses the input system and auto-detects if it's mouse or keyboard/controller, swapping a bunch of stuff around on the fly as it detects things.
All of my Dialogue System stuff works great with either controller as long as I don't swap in the middle of a conversation. If I'm using the mouse and try to go to the controller, it doesn't return focus to either the Continue button or the first of the dialog options (if those are currently available). I've checked and the background code is still definitely working.
I don't want to use Always Auto Focus because that means dialog selections always have the top option focused when I'm using the mouse.
Is there a fast line I can chuck in my pre-existing code to just always focus the top button or continue button if the Dialog System conversation panel is open and it detects controller input?
Code for forcing focus back on continue/first dialog option?
-
- Posts: 6
- Joined: Thu Mar 28, 2024 7:20 pm
Re: Code for forcing focus back on continue/first dialog option?
Hi,
The quick way is to manually set the Input Device Manager component's Input Device with a line of code when you switch to a joystick (controller), such as:
For example, you could hook into the C# event InputSystem.onDeviceChange.
When the Input Device Manager component's Input Device is set to Joystick, it will keep the continue / response menu buttons focused. (If you need to turn off this forced focus, see How To: Pause Dialogue In Menus.)
In the next version of the Dialogue System, the Input Device Manager will hook into InputSystem.onDeviceChange and update the Input Device automatically.
The quick way is to manually set the Input Device Manager component's Input Device with a line of code when you switch to a joystick (controller), such as:
Code: Select all
InputDeviceManager.instance.SetInputDevice(InputDevice.Joystick);
When the Input Device Manager component's Input Device is set to Joystick, it will keep the continue / response menu buttons focused. (If you need to turn off this forced focus, see How To: Pause Dialogue In Menus.)
In the next version of the Dialogue System, the Input Device Manager will hook into InputSystem.onDeviceChange and update the Input Device automatically.
-
- Posts: 6
- Joined: Thu Mar 28, 2024 7:20 pm
Re: Code for forcing focus back on continue/first dialog option?
Works like a charm! Thanks a ton.