Hi everyone, my scrollview script is acting weird. When I try to put a GUILayout.Box into void OnGUI it appears as an extremely tiny box and no matter what I can’t change its size. I can’t quite figure out what’s causing this. I think it might have something to do with the BeginScrollview function in my script but I’m not positive.
private Vector2 scrollPosition;
public int Switchint = 1;
void OnGUI()
{
GUI.BeginGroup(new Rect(525, 275, Screen.width/2,
Screen.height/2));
GUILayout.Box("20", GUILayout.Width(200));
switch(Switchint)
{
case 1:
scrollPosition = GUILayout.BeginScrollView(scrollPosition,
GUILayout.Width(150), GUILayout.Height(150));
GUI.EndScrollView();
GUI.EndGroup();
break;
case 2:
break;
case 3:
break;
default:
break;
}
I switched to BeginArea and that fixed my Box problem but now for some reason I can’t move my scrollview with the coordinates from BeginArea. It’s just stuck on the edge of the screen.
edit: I tried removing the beginscrollview to see if that would fix the problem. it did but I need the beginscrollview for my script. Why does Beginscrollview seem to cause a lot of problems?
Here is what the code looks like now
private Vector2 scrollPosition;
public int Switchint = 1;
void OnGUI()
{
GUILayout.BeginArea(new Rect(525, 275, Screen.width/2,
Screen.height/2));
GUILayout.Box("20", GUILayout.Width(200));
switch(Switchint)
{
case 1:
scrollPosition = GUILayout.BeginScrollView(scrollPosition,
GUILayout.Width(150), GUILayout.Height(150));
GUI.EndScrollView();
GUILayout.EndArea();
break;
case 2:
break;
case 3:
break;
default:
break;
}