Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
joonavav's avatar
joonavav
Honored Guest
1 year ago

How to manage ray interactions on multiple Unity Canvases on top of each other?

Hi,

How do I manage disabling and enabling multiple world space canvases so the Ray interactions work properly, when the canvases are placed in front of each other?

The UI canvases are default Unity world space canvases with ray interactions added with the quick actions described in this article: Add an Interaction with QuickActions | Oculus Developers

The problem is that I have two worldspace canvases with ray interactions placed in front of each other, kinda like in layers. When I disable the canvas gameobject in front, the interactor cursor hits the disabled (invisible canvas) and does not properly pass through to hit the second canvas (which it should do).

How can I ensure the cursor interacts with the first active/visible canvas and does not get captured by disabled ones?

4 Replies

Replies have been turned off for this discussion
  • Anton111111's avatar
    Anton111111
    Expert Protege

    I made myself a prefab that contains an empty object and a canvas and collider nested in it. Accordingly, when I turn off the object, the collider and canvas are turned off.

  • I'm not saying this is a definitive solution, but here is what I did.

    Setup a parent canvas go with all canvas components, graphic raycaster, pointable canvas and ray interactable scripts in the inspector. This canvas is empty (has no UI elements). Setup ISDK_RayInteraction (Right click gameobject -> Interaction SDK -> Add Ray Interaction to Canvas). This is your interactable canvas.

    Setup your canvases as children of the parent you have just made. Make sure they do not have any XR components, like pointable canvas/ray interactable scripts, or ISDK_RayInteraction. Set them up as you would normally.

    You should then be able to add UI elements to your child canvases and all should all be interactable.

    Hope this helps someone!