Is it possible to detect when the user clicks with the mouse outside a GUI's area? I wanted to call my GUI's close method when that happens but I have no idea how to detect such event in the correct way.
asked Aug 20, 2012 at 01:01 AM
Well there's no built in way to detect this. You have to check it manually. When you use a GUI window or group / area, you can use its Rect to check if the mouse is inside.
Here's the same thing in UnityScript.
This is the closest as it gets so far:
I get the mouse coordinates X and Y, and check if they are in the GUI's boundaries, I guess this is the most efficient as it gets in GUIs. I wasn't able to use
because of that error i commented above.
Hope this helps someone with the same question in the future.