- Home /
How to click on button that is behind transparent image in New UI?
I'm having trouble finding out how to click on a button that is behind a image that I use as a mask of some sort. Can i make that image unclickable? It seems reasonable that images are unclickable objects, but when the image is in front of the button then I cant get buttons to work. After I move the image in hierarchy or disable game object the click works.
Is there any way to handle what is clickable and not in the new UI? (I've tried ignore raycast layer with no luck)
Thank you in advance.
Answer by Mmmpies · Feb 10, 2015 at 10:59 AM
You can put a CanvasGroup on the panel and untick interactable and blocksRaycast or move the button down the hierarchy when you want it in front of the panel. Not got access to unity so from memory its setlastsibling.
panel object doesn't have interactable checkbox dude. And i need mask in front of the buttons for visual effect, as I've stated above I know that i can move elements down and up both manually and via script. Im looking into the Canvas.GraphicRaycasterScript now to see if i can do sonething with it
Highlight the panel.
Click Add Component -> CanvasGroup
The tick boxes are on there.
Thanks you it worked but kinda retarded way to do it, complicates stuff a lot. Thanks anyway man. (Y)
Hey I didn't create the UI, but I can see how having a separate component that can make any UI element or group of elements visible/interactable/blockRaycast is neater than adding all of those to each UI component as default.
Yeah no bad things meant to you man, I'm just annoyed untill I get more comfort with the new UI. You helped me thus you rock :D
Answer by Carlotes247 · Dec 21, 2015 at 02:58 AM
Hello, just to update it with Unity 5.3, you can deselect a boolean field in the Image component, called "Raycast Target". It ignores the raycast of the event system and there is no need of adding another component :)
This is ABSOLUTELY the best way to do it, this should be the answer! Way many kudos, been making panels, and it didnt work properly.
Your answer
Follow this Question
Related Questions
Image in Button is cut (New UI) 2 Answers
Detect Input type by checking if ANY key on keyboardd/joypad is pressed 1 Answer
Best Button for UnityGame 2D 1 Answer
Prevent Button from tinting child Images 1 Answer
Scrollable Achievement Tabs? 1 Answer