I’m trying to make my own ‘console’ of sorts in a custom Editor Window. I want it to work more or less the same as the regular console: messages are rendered inside rects which are stacked vertically inside a larger, scrollable rect, which is embedded in my editor window.
So far this is what I have:
which is created through the following code:
private void ConsoleDrawer()
{
float margin = 20f;
Rect rect = new Rect(margin, 100f + margin, Screen.width - (margin * 2), Screen.height - 200f);
GUILayout.BeginArea(rect, GUI.skin.box);
m_debugConsoleScroll = GUILayout.BeginScrollView(m_debugConsoleScroll, false, true);
GUILayout.BeginVertical();
for (int i = 0; i < 1000; i++)
{
GUILayout.BeginArea(new Rect(-2f, 30f * i - 1f, Screen.width, 30f), GUI.skin.box);
GUILayout.EndArea();
}
GUILayout.EndVertical();
GUILayout.EndScrollView();
GUILayout.EndArea();
}
This seems quite similar to all the examples I can find elsewhere, but no matter how I order things or what parameters I change, the scroll area never seems to work how I want it to, i.e. grow to accommodate all 1000 smaller rects.