private void checkForPopupClose()
{
// HACK: Since clicking on nothing doesn't remove a control's input focus,
// we don't necessarily get any sort of automatic notification that the user
// has clicked outside of all focusable controls. We have to poll for such
// a condition manually.
if( popup == null || !Input.GetMouseButtonDown( 0 ) )
return;
var camera = GetCamera();
var ray = camera.ScreenPointToRay( Input.mousePosition );
RaycastHit hitInfo;
if( triggerButton != null && triggerButton.GetComponent<Collider>().Raycast( ray, out hitInfo, camera.farClipPlane ) )
return;
if( popup.GetComponent<Collider>().Raycast( ray, out hitInfo, camera.farClipPlane ) )
return;
if( popup.Scrollbar != null && popup.Scrollbar.GetComponent<Collider>().Raycast( ray, out hitInfo, camera.farClipPlane ) )
return;
if( this.GetComponent<Collider>().Raycast( ray, out hitInfo, camera.farClipPlane ) )
return;
ClosePopup();
}