Search Unity

RayCasting with Google Cardboard

Discussion in 'AR/VR (XR) Discussion' started by jules_fpvr, Jan 19, 2018.

  1. jules_fpvr

    jules_fpvr

    Joined:
    Jan 8, 2016
    Posts:
    35
    I have an application in Unity 2017.3.0p2, in which I have an extra input module that does some ray casting, using:

    Code (CSharp):
    1. eventSystem.RaycastAll(pointerData, m_RaycastResultCache);
    My app has a single Camera iwht a PhysicsRaycaster attached and when I run this in Editor or on Android then it works exactly as I expect.

    My application starts up and immediately successfully loads the Cardboard SDK and until I set XR.XRSettings.enabled = true it works fine.

    As soon as I enable XR mode the ray casting stops returning.

    Does anyone know of any differences between the way the EventSystem / RayCasting works in XR mode vs normal?

    Or, any suggestions as to how to debug?

    Thanks

    Jules
     
  2. jules_fpvr

    jules_fpvr

    Joined:
    Jan 8, 2016
    Posts:
    35
    I finally found this answer. Which basically says that in VR mode you can't use Screen.width and height as the basis for your ray casting position, but instead need to use the VR texture size. Which you can get from XR.XRSettings.eyeTextureWidth/Height.

    Just tried it and it worked.
     
    mgear likes this.