Search Unity

Oculus VR mode Input.MousePosition wrong for WorldSpace Canvas uGUI

Discussion in 'AR/VR (XR) Discussion' started by Metatronics, May 9, 2015.

  1. Metatronics

    Metatronics

    Joined:
    May 9, 2015
    Posts:
    1
    I am running the Oculus with a uGUI canvas running in worldspace mode so that it becomes stereoscopic for VR mode. Along with a world space cursor. Everything works fine, and working as expected. Except that when the Oculus mode is enabled. It changes the mouse sensitivity to accommodate for the split screen. So that a full sweep of the mouse from left to right of the window results in half a sweep in the game. This makes sense and does the right thing since it is a side by side split screen now. But the problem is in the MousePosition.Y this has also been reduced to half. Which results in only getting a mouse Y value half way up for a full sweep up the screen. I can understand that if they didn't do this the mouse would move at half speed in the horizontal and full speed in the vertical. And would feel weird to a user.
    This won't matter to anybody unless they want to use the built-in gui in vr mode. As you can normally you can get around this by using mouse deltas and lock and center the "real" cursor. And produce a software cursor (worldSpaceCursor) using raycasting to do 3D object selection.

    But when it comes to running the 4.6+ gui (uGUI) you can't fake the system into believing where the mouseposition is otherwise for the GUI. Resulting in the mouseposition only working on the lower half of the game before it hits (the actual cursor) the top of the screen. As you don't tell the gui anything about where the mouse will be for enter/hover/click/select/ etc...

    The only solution I can see is to detect and trigger all gui events myself ignoring the built-in system so that I can go back to a delta based mouse, which is not trivial.

    Any solutions?
     
  2. OpticalOverride

    OpticalOverride

    Joined:
    Jan 13, 2013
    Posts:
    161
    Funny, I think I made a post on this back in December, here's the link:

    http://forum.unity3d.com/threads/fake-mouse-position-in-4-6-ui-answered.283748/

    If I'm not missing anything, I think the second post I made in that thread (I answered my own question) is what your looking for. In that thread I rewrote the UI code (which I'm assuming is still open source?) to "fake" mouse positions to the UI event system. The code for the new 4.6 UI has likely changed since that post, but hopefully it's still similar enough that my code will get you in the ballpark.

    Hope this helps!