I have a clickable 3d object in the scene rendered by the main camera. The main camera has a PhysicsRaycaster attached and the object a normal box collider for example so its clickable as wanted.
Then I add a transparent HUD with a button for example which should be rendered always on top of normal 3d scene, so a HUD gameobject with a canvas which contains the button at some place on the screen.
My question is how do I setup the canvas so that I can click the button in the HUD but still are able to click the 3d object in the scene as well. Here are the ways I already tried:
- Set Canvas to screen space overlay plus a GraphicsRaycaster next to the Canvas. The HUD is clickable but all clicks are intercepted by the GraphicRaycaster and never reach the PhysicsRaycaster of the main camera so the 3d object is not clickable anymore
- Set Canvas to screen space camera, now the HUD neets to be placed very close to the main camera (canvas->plane distance) otherwise the UI is rendered behind the 3d objects. Placing the Canvas so close to the main camera will again block all rays to hit the 3d objects in the scene
- So instead keeping the canvas->plane distance at a high distance but rendering the canvas with a separate camera on top of the main camera is the closest I got. The HUD is always on top of the 3D objects and both the HUD elements and the 3d objects are clickable excapt if a clickable 3d object is now physically in front of the HUD the 3d object is clicked and not the HUD element.
Its probably some stupid mistake by me but I can’t figure out how to do this the right way