Pretty much the title. I have 2D scene where i put multiple scenes as additive, and what I’m struggling with is that i have 2 buttons that are behind each other in 2 separate scenes. When i click on the butto that is at the most top layer, the “click” interacts with the bellow button. How can i prevent such behaviour when having multiple UI elements on top of another? What i tried was:
Put them on different layers and insert “Image” between them with disabled raycast - but it didn’t help still detect’s the raycast because the buttons are on top of each other.
Removed the “Button” component and only left them as “Image” and set new script which handles “IPointerDownHandler” but still the same behaviour.
I really don’t get how the raycast handles things at the moment, can someone explain what is happening when having multiple UI objects behind each other ?
@d3x7er if you add a Canvas Group to an UI element, then enable block raycasts option. It should block raycasts to elements behind it. But to be honest I’m not sure what happens when you load new scenes and which scene is the topmost one etc. And you have multiple canvases too.
Just tried with “Canvas Group” as you suggested but sadly it still raycasts everything. But there is a glimpse of hope at least if I can’t find a solution i can just block the canvas i don’t want to raycast with the option in “Canvas Group” interactable to false and it should work, but it will be a bit of ugly solution when working with multiple canvases and different scenarious, at least it’s something
So I decided to fully try this out with Canvas Group moved every dialog/popup in every scene to separate canvases and made a delegate with which i controll what I am showing and from which Scene it is and decide which canvas should disable (raycast & interactable) and it is actually not bad, not that ugly and most important it works.