Search Unity

[Solved] Raycasting to UI on a different layer

Discussion in 'VR' started by Swiftle, Jan 16, 2020.

  1. Swiftle

    Swiftle

    Joined:
    Feb 11, 2014
    Posts:
    38
    Hello,

    In my current setup I'm displaying the UI in front of other objects by using the following setup.

    1. The UI is on a special layer (let's say VR_UI layer)
    2. A camera that renders Depth Only and VR_UI layer is a child of my main camera
    3. The canvas renders in World Space with the event camera being the UI cam.
    4. The raycaster (OVRRaycaster) has the blocking mask only set to VR_UI.

    However the ray isn't getting blocked by any of the elements present in the UI.
    Could someone help me and tell me what I'm doing wrong?
     
  2. Swiftle

    Swiftle

    Joined:
    Feb 11, 2014
    Posts:
    38
    Turns out the above setup was working correctly. In the end I unparented the UI cam from the main one to prevent the UI from following the head movements.