Hello!
I'm newbie and I currently learning VR development using the Google Cardboard XR Plugin. In my project, I've integrated dialogs that activate when the pointer/reticle is aimed at specific objects.
In Unity, when the reticle (from Cardboard) is directed at each response buttons and I hit space on the keyboard, they function correctly
However, when running on a smartphone and pressing a joystick button (alt positive button), it always selects the first response button. This happens even when the reticle is not aimed at any response button.
Is there a solution to overcome this issue?
Google Cardboard XR Interaction
Re: Google Cardboard XR Interaction
Hi,
Are there any errors or warnings in the Console window?
If not, then please see below:
The Dialogue System uses Unity UI.
In Unity UI, a GameObject called EventSystem handles interaction with UI buttons such as the Dialogue System's response buttons.
The EventSystem keeps track of which UI button currently has focus, which it calls "selected." To see which UI button is currently selected, you can keep an Inspector view on the EventSystem GameObject while you're playing in the Unity editor's play mode. The bottom of the Inspector will show which UI button is selected.
The EventSystem also listens for inputs from your input device, such as a joystick or keyboard. To simplify it a bit, if you press up or down on the joystick, this will change the EventSystem's Vertical input value. If the Vertical input value changes, the EventSystem will change the selection to the response button that's above or below the current selection. If you press the Submit input (typically mapped to the Space & Enter keys and the A button on an Xbox joystick, X button on PlayStation joystick, etc.), then it will click the UI button.
If no UI button is currently selected, then the EventSystem's Vertical input will have no effect. Since no UI button is selected, the EventSystem doesn't know which response button to select next. Similarly, if no UI button is currently selected, the Submit button will have no effect.
To handle this, the Dialogue System's Dialogue Manager GameObject has a component called Input Device Manager. If the Input Device Manager's Always Auto Focus checkbox is ticked, it will always keep a UI button focused (selected) so you can navigate the UI buttons with a joystick.
What's probably happening is that the Input Device Manager is selecting the first response button. So, when you press the joystick input button, the EventSystem clicks the first response button.
Try UNticking the Dialogue Manager's Input Device Manager component > Always Auto Focus if it's ticked, and clear the Joystick Key Codes/Buttons/Axes To Check.
Are there any errors or warnings in the Console window?
If not, then please see below:
The Dialogue System uses Unity UI.
Dialogue System is actually UI-system independent
Actually, the TMI (too much information) is that the Dialogue System is UI-independent. It can work with any UI system. But, by default, it works with Unity UI.
The EventSystem keeps track of which UI button currently has focus, which it calls "selected." To see which UI button is currently selected, you can keep an Inspector view on the EventSystem GameObject while you're playing in the Unity editor's play mode. The bottom of the Inspector will show which UI button is selected.
The EventSystem also listens for inputs from your input device, such as a joystick or keyboard. To simplify it a bit, if you press up or down on the joystick, this will change the EventSystem's Vertical input value. If the Vertical input value changes, the EventSystem will change the selection to the response button that's above or below the current selection. If you press the Submit input (typically mapped to the Space & Enter keys and the A button on an Xbox joystick, X button on PlayStation joystick, etc.), then it will click the UI button.
If no UI button is currently selected, then the EventSystem's Vertical input will have no effect. Since no UI button is selected, the EventSystem doesn't know which response button to select next. Similarly, if no UI button is currently selected, the Submit button will have no effect.
To handle this, the Dialogue System's Dialogue Manager GameObject has a component called Input Device Manager. If the Input Device Manager's Always Auto Focus checkbox is ticked, it will always keep a UI button focused (selected) so you can navigate the UI buttons with a joystick.
What's probably happening is that the Input Device Manager is selecting the first response button. So, when you press the joystick input button, the EventSystem clicks the first response button.
Try UNticking the Dialogue Manager's Input Device Manager component > Always Auto Focus if it's ticked, and clear the Joystick Key Codes/Buttons/Axes To Check.