My TextArea doesn’t scroll with ScrollViewScope but it works with Begin/EndScrollView. Using the fixed sample code from TextArea:
public class TextAreaExample : EditorWindow
{
string text = "Nothing Opened...";
TextAsset txtAsset;
Vector2 scroll;
Vector2 scroll_for_scope;
[MenuItem("Examples/TextArea usage")]
static void Init()
{
TextAreaExample window = (TextAreaExample)GetWindow(typeof(TextAreaExample), true, "EditorGUILayout.TextArea");
window.Show();
}
Object source;
void OnGUI()
{
source = EditorGUILayout.ObjectField(source, typeof(Object), true);
TextAsset newTxtAsset = (TextAsset)source;
if (newTxtAsset != txtAsset)
ReadTextAsset(newTxtAsset);
using (new GUILayout.HorizontalScope())
{
using (new GUILayout.VerticalScope())
{
GUILayout.Label("Begin/EndScrollView");
// original example has the GUIStyle parameters wrong, but this works.
scroll = EditorGUILayout.BeginScrollView(scroll, GUILayout.Height(position.height - 30));
{
EditorGUILayout.TextArea(text, GUILayout.ExpandHeight(true));
}
EditorGUILayout.EndScrollView();
}
using (new GUILayout.VerticalScope())
{
GUILayout.Label("ScrollViewScope");
// this looks right, but doesn't scroll
using (new EditorGUILayout.ScrollViewScope(scroll_for_scope, GUILayout.Height(position.height - 30)))
{
EditorGUILayout.TextArea(text, GUILayout.ExpandHeight(true));
}
}
}
}
void ReadTextAsset(TextAsset txt)
{
text = txt.text;
txtAsset = txt;
}
}