private void DrawPopupContents(int windowId)
{
GUI.BringWindowToFront(windowId);
var pos = popupPos;
var c = callback;
bool shouldClose = callback(windowId, parameter);
if (shouldClose && c == callback)
{
showPopup = false;
}
// Close the popup window if clicked somewhere outside it
if (c == callback && (Input.GetMouseButton(0) || Input.GetMouseButton(1) || Input.GetMouseButton(2)))
{
var mousePos = new Vector3(Input.mousePosition.x, Screen.height - Input.mousePosition.y, Input.mousePosition.z);
if (!pos.Contains(mousePos))
{
showPopup = false;
}
}
}