- Home /
How to stop collider from interfering with world space canvas?
Hi all!
I have a canvas that is in world space and a normal box collider behind it. But my buttons cannot be clicked because of the collider behind the canvas (and the collider/object is definitely behind the canvas). How can I make the canvas be in front of everything including colliders?
Thanks
It doesn't seem like the collider behind the canvas is the problem...
Can you click the buttons if there is nothing behind the canvas? How are your layers sorted? For any world space canvas that I have I always make sure they're on a dedicated UI layer so no raycasts that are meant for world objects interact with them, and no UI raycasts interact with anything in the world.
yeah, it does work if nothing is behind it. And the canvas is on the normal UI layer (I haven't changed anything with how the layers are sorted). So you say it should not be on the normal UI layer?
How is your camera system set up? Is the same camera used for both world and for UI layer? Try using one camera for world and everything except UI, and another camera with larger Weight property (so it's drawn later), with Clear to Depth Only, and it only renders the UI layer and nothing else.
Answer by YoungDeveloper · Jun 02, 2016 at 11:06 AM
Mark all UI with layer UI and when raycasting specify which layers you want to hit using bit shifting. That will give you solution to raycast everything except ui or certain layers only. UI layer is already created for you in unity editor.
Yeah but he's not manually doing raycasts, he's literally just clicking the UI buttons with the mouse as far as I understood it. So the raycast should be handled automatically behind the scenes, and it does, though for some reason it gets blocked by world objects (on the opposite side of the canvas, to make it even weirder).
I don't believe you can access the raycast mechanics of UI clicking system, can you?
Your answer
Follow this Question
Related Questions
World Canvas and Locked Cursor 0 Answers
UI image with collider doesn't work OnMouseDown 1 Answer
Canvas problem with render mode : World Space 0 Answers
How to make World Space Canvas be on top of Overlay Canvas? 0 Answers
Issues with world space canvas for different resolutions. Any Workaround ? 0 Answers