Scrollview PROBLEM

Hi there,

i try to use ScrollView, but does’n work.
He appear but i can’t move.

This is the code:

        float width = 300;
        float height = 350;
        Rect rectBackground = new Rect((Screen.width/2) - 20, 50, width, height);
        
        GUILayout.BeginArea(rectBackground,GetBackgroundStyle(rectBackground));

        
        GUILayout.BeginScrollView(new Vector2(Screen.width / 2,50));
        GUILayout.Box(menu.ToString());

       --
       ALL OF GUI HERE
       --

        GUILayout.EndScrollView();
        GUILayout.EndArea();

Somebody can help me?

Thanks

You’re passing a fixed scroll position into BeginScrollView(). Per the example in the documentation, you need to keep the scroll position in a variable and update it from BeginScrollView()'s return value:

Vector2 scrollPos = Vector2.zero;

void OnGUI() {
    scrollPos = GUILayout.BeginScrollView(scrollPos);
    ...
    GUILayout.EndScrollView();
}

Thanks,

Works fine.

:wink: