Mouse Click not detected

I have a script that has an OnMouseDown function, and toggles a boolean value. The object I want the script attached to is a child object, 2 or 3 levels deep in my main parent game object. If I attach the script to that main parent object or any of its children, it doesn’t do anything. If I attach the script to any other object in my scene, it works as expected. All of the objects I try to use have a box collider component.

Is there any reason why this would be happening?

This might be stupid, but is there a chance that OnMouseDown could be getting called multiple times or getting called from OnGUI by the object in question?

I've had trouble in the past using someBoolean = ! someBoolean when certain functions return true multiple times.

For example, I first tried to use this when impementing keyboard shortcuts with Input.GetKey and determined that I had to use Input.GetKeyDown. Using GetKey would return true multiple times, which would rapidly toggle the value with unpredictable results.

That being said, you're using OnMouseDown() which is part of MonoBehaviour... And it doesn't sound like this matches your issue... So all this typing is probably a waste of time.

I guess this would only apply if you're explicitly calling OnMouseDown from another script.