- Home /
Question by
ILLUSION2006 · Jul 02, 2020 at 05:33 PM ·
c#ui2d gamepanel
Make Only Certain UI block raycast/touch
I have a panel which turns on and off at certain points, when I want nothing to be clickable if it is behind the panel. I used this code to achieve this - if (EventSystem.current.IsPointerOverGameObject()) return; However this makes my canvas also block everything making the game unplayable, is there a way to modify this code so only the panel blockes touches/raycast
Comment
Answer by HappyPixel27 · Jul 03, 2020 at 01:32 AM
In your Canvas, make sure whatever you are putting in front of the clickable objects is closer to the bottom than whatever is behind it.
For example Canvas Button Image (Image blocks the button from being pressed)