- Home /
Do OnMouse functions work on child colliders?
I'm in the initial stages of setting up some button functionality for my game and was planning on using the following structure:
Have an empty game object called "Interface Controller" and attach an InterfaceController script
Add a child game object with a collider for every button
Using OnMouseDown in the InterfaceController script, check the tag of the collider object to perform button action
However, the OnMouseDown function is not triggering for the child object colliders. I'm using a really simply script to test:
void OnMouseUpAsButton()
{
Debug.Log("Clicked!");
}
It will work when I attach the script to the child object, but not the parent. It seems really messy to have the same script or a unique script attached to every button. Is there any way I can do this from the parent?
There of cours is a solution, but I dont see the point doing it. Rather I would use a simple messaging system like CSNotificationCenter and post notifications in the childs, and processing the event in the parrent.
Your answer

Follow this Question
Related Questions
Internal collisions 1 Answer
OnMouseEnter not working 6 Answers
How can I call OnMouse functions on a specific collider? 2 Answers
Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer
Can one click trigger 2 colliders? 1 Answer