79389517

Date: 2025-01-27 00:16:32
Score: 2.5
Natty:
Report link

I wrote a script to do some stuff whenever Input.GetMouseButtonDown came true after a click anywhere on the screen. I added the script to an otherwise empty Game Object "Z". It works fine. I wrote another script to do some other stuff whenever OnMouseDown() came true while the mouse was above a particular Game Object "X" but according to my debugs this code never gets called. I added this script to Game Object X, which starts off inactive but gets activated later. The first mouse detection continues to work fine. The second script did work briefly but now doesn't! X is a child of another Game Object "Y" and is physically (i.e. on the screen) within the box of Y. If I add the same code to Y as is in X (but changing the debug messages) then Unity always detects clicks within Y (as well as Z) but never on X. Is there something I don't understand about mouse activity in my scene or is it more likely I have made a silly coding error?

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Ends in question mark (2):
  • Low reputation (0.5):
Posted by: reallydismayed