Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved XRUI Input Module conflicts with traditional mouse-operated UI

Discussion in 'XR Interaction Toolkit and Input' started by datagreed, Oct 23, 2020.

Thread Status:
Not open for further replies.
  1. datagreed

    datagreed

    Joined:
    Sep 17, 2018
    Posts:
    42
    I am building a game with one player in VR and second player on the same computer using keyboar, mouse and a monitor.

    By default UI for the non-VR player was behaving odd - mouse hovers were registered for a split second and then registered only when mouse moved (e.g. you hover on a button and it highlights for only a couple of frames) and mouse drag was not working at all. Only mouse clicks were registered. Seems like a bug.

    I noticed that XRInteraction toolkit automatically adds XRUIInputModule to a game object with EventSystem on it.

    Disabling XRUIInputModule fixes a problem for non-VR player, but poses a problem for a VR player: now you cannot interact with UI in VR.

    I tried disabling Mouse Input in XRUIInputModule, but it did not help.

    How can I have both VR and non-VR UI interaction to work properly at the same time?
     
  2. foonix

    foonix

    Joined:
    Dec 15, 2019
    Posts:
    20
    If doing completely separate builds, consider a compile time constant that just tells some monobehavior to turn `XRUIInputModule` depending if the game was built for VR or not.

    Code (CSharp):
    1. #if ENABLE_VR
    2. GetComponent<XRUIInputModule>().enabled = true;
    3. #else
    4. GetComponent<XRUIInputModule>().enabled = false;
    5. #endif
    The mouse cannot really be used as a normal cursor VR mode because the mirror view blit does not line up with raycasting from the camera center. (Or at least: It didn't when I tried it.)

    I'm running both modes in the same build and there are a lot of gotchas but it does work. The player can even change to VR mode from a config menu in game. This requires a monobehavior to basically turn on/off the necessary components depending on if the user is in VR or not. I basically am using camera prefab that contains the XR sitting camera rig, but with a script that hobbles it to act like a normal camera when VR is not turned on.
     
    valdeezzee likes this.
  3. mfuad

    mfuad

    Unity Technologies

    Joined:
    Jun 12, 2018
    Posts:
    334
    We believe there were a few related known issues that have now been fixed in XRI 0.10 preview. More information can be found in our recent forum post. If you're still having issues, please file a bug and the team will take a look. Thanks!
     
Thread Status:
Not open for further replies.