- Home /
Multiple objects with OnMouseDown
It is my understanding that the OnMouseDown function is called for whatever collider or GUI element is under the mouse when the button is clicked. However, it appears to be the case that only the first element hit has its function called, and none of the subsequent elements that may be under the mouse. Is it possible to cause other elements to also have this function called for them, in a sense changing the logic from a Raycast type test to more of a RaycastAll type of test?
Answer by Eric5h5 · Nov 01, 2011 at 01:15 AM
You have to write your own code using RaycastAll; there isn't a way to change built-in behaviors.
I was afraid that might be the answer, but I appreciate your feedback.
Answer by Rod-Green · Nov 01, 2011 at 01:47 AM
You could try using "HitTest" instead.. http://unity3d.com/support/documentation/ScriptReference/GUILayer.HitTest.html?from=GUIElement
Your answer
![](https://koobas.hobune.stream/wayback/20220613025742im_/https://answers.unity.com/themes/thub/images/avi.jpg)