Hello,
Let's say I have a UI Panel that covers part of the screen, and other UI buttons in the HUD outside the panel that trigger other panels. I want to do two things:
- If the player clicks outside the panel, I want the panel to close.
- Additionally, if the player's click falls outside the panel on another button, I'd like it to close the current panel and open the new target panel.
I could hack #1 by adding an invisible collider in the empty space around each panel, but that would make #2 difficult. And I'd rather not have to add extra colliders to every panel I have.
What I'm looking for is a way for each UI element to receive an event like, "There was a click and it wasn't on me." That way I could use that to deactivate the panel, and the click can then run its normal course, whether it fell on another UI button or not.
Is there a way to do this?