// Begin an automatically laid out scrollview.
public static Vector2 BeginScrollView(Vector2 scrollPosition, bool alwaysShowHorizontal, bool alwaysShowVertical, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background, params GUILayoutOption[] options)
{
GUIUtility.CheckOnGUI();
GUIScrollGroup g = (GUIScrollGroup)GUILayoutUtility.BeginLayoutGroup(background, null, typeof(GUIScrollGroup));
switch (Event.current.type)
{
case EventType.Layout:
g.resetCoords = true;
g.isVertical = true;
g.stretchWidth = 1;
g.stretchHeight = 1;
g.verticalScrollbar = verticalScrollbar;
g.horizontalScrollbar = horizontalScrollbar;
g.needsVerticalScrollbar = alwaysShowVertical;
g.needsHorizontalScrollbar = alwaysShowHorizontal;
g.ApplyOptions(options);
break;
default:
break;
}
return(GUI.BeginScrollView(g.rect, scrollPosition, new Rect(0, 0, g.clientWidth, g.clientHeight), alwaysShowHorizontal, alwaysShowVertical, horizontalScrollbar, verticalScrollbar, background));
}