The UI struggle continues, plus XR!

I feel like I'm hitting every shared experience working with the virtual mouse input component. This is the most recent one about the cursor position jumping back to the last virtual position when going back and forth between the actual mouse and the virtual mouse. Same deal but this time with clicks.

By manually turning off the Virtual Mouse component when I'm using the system mouse, the UI interactions work as intended. Happy about that, not so happy about the two of them not being able to stay synced. I attempted to use the scripts referenced above, but had no luck. I actually ended up disabling the GameObject with the Virtual Mouse Input component entirely. Instead, I'm using the code I had before to warp the mouse position.

OK, WEIRD. I don't know what I changed or how it started working, but directional navigation in the UIs (at least for scene selection) are now working. The Cursor + Virtual Mouse stuff is all disabled, and it only starts working once I use the mouse to click on a scene. But once it has focus, it's just... working?! And the same thing does not work for the main controls to begin a scene/calibrate, etc. Possibly because the scene selection canvas has a grid layout group component, so it's got built-in support for that.

Things like this build up over time, and before you know it, you're > 50% convinced that making your own engine would just be better, and somehow faster.

Whelp, I got frustrated surveying the landscape of folks with similar issues, so I stepped away from the KBM/gamepad inputs and worked on getting the Index to be recognized. Involved the following:

  • Switching SteamVR to be the default system provider for OpenXR
  • Adding Valve Index controller schemes in Unity XR Plugin Management
  • Rebinding the input actions for locomotion, pointing, etc.

I also wanted a way to delay the launch of VR mode, so that's being done with InitializeLoader and StartSubsystems calls. In doing so, I found a very nice way to make a coroutine wait for another coroutine to complete: simply call:

yield return StartCoroutine(OtherCoroutine());

Overall this worked, but the player height became drastically high in doing so. This wasn't the case when the XR provider is configured to initialize at startup for your platform. You'd think the fix would involve having manual checks for player height vs. the floor, etc., but my gut told me to just disable the XROrigin component by default and enable it after the XR subsystems are started. Voila! As far as I can tell, doing so didn't cause any issues in desktop mode, which is nice.