- Home /
Question by
vogles · Jul 17, 2015 at 08:25 AM ·
guilayouteditorscriptbeginarea
Why are GUILayout controls started before the BeginArea they are wrapped in?
I'm working on an editor script and I've got this bit of code:
void OnGUI()
{
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
EditorGUILayout.Space();
EditorGUILayout.EndHorizontal();
var sidebar = GUILayoutUtility.GetLastRect();
sidebar.x = Screen.width - 300;
sidebar.y = sidebar.height;
sidebar.width = 300;
sidebar.height = Screen.height - sidebar.height;
GUI.Box(sidebar, "");
GUILayout.BeginArea(sidebar);
GUILayout.Button("Area Test");
GUILayout.EndArea();
}
For some reason the Button appears above the area specified by the call to BeginArea. Specifically, it behaves as if the origin of the button was bottom left, instead of top left as it should be.
Here's a screenshot of what's going on:
beginarea.png
(8.1 kB)
Comment