Inheritance: GUILayoutGroup
Exemplo n.º 1
0
        // 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));
        }
Exemplo n.º 2
0
        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));
        }