I am making an editor script. In the documention of PopUpWindow I saw an example like this:
Rect buttonRect;
void OnGUI()
{
GUILayout.Label("Editor window with Popup example", EditorStyles.boldLabel);
if (GUILayout.Button("Popup Options", GUILayout.Width(200)))
{
PopupWindow.Show(buttonRect, new PopupExample());
}
// This line is the one I don't understand
if (Event.current.type == EventType.Repaint) buttonRect = GUILayoutUtility.GetLastRect();
}
}
So the line:
if (Event.current.type == EventType.Repaint) buttonRect = GUILayoutUtility.GetLastRect();
Why is it being used? What is it doing?