- Home /
OnMouseDown over multiple Colliders.
I have a few overlapping GameObjects in my Scene. Each one has a Script containing the OnMouseDown function, a Collider2D and a SpriteRenderer. When I click the region where the Colliders intersect, I would expect the GameObject that is rendered on top of all the others to execute its OnMouseDown function. But that is not the case.
Any Ideas why or how to make sure the GameObject rendered last also executes?
I don't think that helps. $$anonymous$$y problem is mainly how Unity / the EventSystem chooses to invoke the function... On$$anonymous$$ouseDown () { print (gameObject.name); }
I mocked up a scene and it works how you expect it to. Which is why I asked to see your code.
Please post the code since it'll make it easier for us to help you :)
Your answer
![](https://koobas.hobune.stream/wayback/20220612210639im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Rendering objects by their y position with a script 0 Answers
Per-Sorting Layer Collision 1 Answer
Transition between levels using 2d colider works once but not repeatidly. 1 Answer
Models using transparent shader are overlapping themselves 3 Answers
How do I set the rendering order of objects with the same sorting layer and order? 1 Answer