>>4248908Instead of having each object execute its logic immediately on click, have them "register" themselves to a central manager script.
1. Collect: On click, every hovered object sends its reference and its Z value to a ClickManager script.
2. Delay: Wait until the end of the frame (or a tiny fraction of a second) so all overlapping objects have time to register.
3. Execute: The manager sorts the list, calls the OnClick event for the object with the highest Z, and clears the list.