0
votes

I am developing a 2d game with Unity. I have a popup settings dialog and When Player clicked settings button it coming to screen on the other objects.

Game objects have got Collider2d component and If a button over an game object which has Collider2d compopnent, Button click action doesn't work.

I use different layers and canvas, and I set z index -20 and more but result is same button click doesn't work.

Here is screen shots; game and scene windows descriptions

1
You only need one canvas. From the bottom right part it looks like the grid is stil in front of the popup. Did you change the camera or do you use the default placement for that? In that case, -z is closer to the camera, so if you have set the grid to -20 you moved in the wrong direction. - Gunnar B.
By grid I mean just the colliders. The graphics are actually behind. - Gunnar B.
Grid is not behind, When I select objects, unity just highlight the colliders. - Savas Adar
What did you set to z -20? The grid or the popup? - Gunnar B.
I was set popup z -20. - Savas Adar

1 Answers

1
votes

The problem was not only about collider overlapping. First part of the problem was image and button overlapping.

I removed the raycast target for Image components in a grid.

enter image description here

But already I can't click button when overlap with a 2d collider.