// 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)); }
// Begin a vertical control group. public static void BeginVertical(GUIContent content, GUIStyle style, params GUILayoutOption[] options) { GUILayoutGroup g = GUILayoutUtility.BeginLayoutGroup(style, options, typeof(GUILayoutGroup)); g.isVertical = true; if (style != GUIStyle.none || content != GUIContent.none) { GUI.Box(g.rect, content, style); } }
public static void BeginHorizontal(GUIContent content, GUIStyle style, params GUILayoutOption[] options) { GUILayoutGroup group = GUILayoutUtility.BeginLayoutGroup(style, options, typeof(GUILayoutGroup)); group.isVertical = false; if ((style != GUIStyle.none) || (content != GUIContent.none)) { GUI.Box(group.rect, content, style); } }
public static Vector2 BeginScrollView(Vector2 scrollPosition, bool alwaysShowHorizontal, bool alwaysShowVertical, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background, params GUILayoutOption[] options) { GUIUtility.CheckOnGUI(); GUIScrollGroup gUIScrollGroup = (GUIScrollGroup)GUILayoutUtility.BeginLayoutGroup(background, null, typeof(GUIScrollGroup)); EventType type = Event.current.type; if (type == EventType.Layout) { gUIScrollGroup.resetCoords = true; gUIScrollGroup.isVertical = true; gUIScrollGroup.stretchWidth = 1; gUIScrollGroup.stretchHeight = 1; gUIScrollGroup.verticalScrollbar = verticalScrollbar; gUIScrollGroup.horizontalScrollbar = horizontalScrollbar; gUIScrollGroup.needsVerticalScrollbar = alwaysShowVertical; gUIScrollGroup.needsHorizontalScrollbar = alwaysShowHorizontal; gUIScrollGroup.ApplyOptions(options); } return(GUI.BeginScrollView(gUIScrollGroup.rect, scrollPosition, new Rect(0f, 0f, gUIScrollGroup.clientWidth, gUIScrollGroup.clientHeight), alwaysShowHorizontal, alwaysShowVertical, horizontalScrollbar, verticalScrollbar, background)); }