Unity Scrolling Textbox

I’m trying to build a GUI scrolling textbox where the content will be of unknown length and will change (but not user editable).

While BeginScrollView is nice, I am forced to determine the scroll height before I build any content, not that there’s any way to poll the height of content or to get a TextArea to auto-adjust its height depending on its content.

Use GUILayout.BeginScrollView if you can it's a lot less troublesome. If you can't then the CalcXXXX methods on GUIStyle will help you calculate the area needed by rendered text. I think these only work in OnGUI so this encourages you to recalculate every OnGUI (that's bad) or have a 'calculated' flag to signal recalculation is needed in OnGUI when new text or data model content is set.

This is what I did:

GUI.BeginGroup(Rect(0,395,250,305));

scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(240), GUILayout.Height(275));

GUILayout.Label(descriptString);

GUILayout.EndScrollView();

GUI.EndGroup();