GUI headach: Scrollview problem

the classes in unity are really great… when you know how to work them lol
but when you don’t, you end up with code that makes no sense at all…
i have a scroll view that contains a label which will be filled during runtime, so it seemed reasonable to use the GUILayout class.
they both should be in a GUI area to make sure they would show up in the right place.
but when i add the scrollview to the area, it didn’t work out… i tried to “tweak” it, and got the wierdest results… sometimes it was in the top left corner, other times it was in the right place but wouldn’t scroll… othertimes it would dissappear :slight_smile:

at the end, i had to use this code which works just fine:

//to control the GUI
var show : boolean = false; 

// the description that will be filled during runtime
var description : String; 

//The variable to control where the scrollview 'looks' into it's child element
private var scrollPosition : Vector2;

function OnGUI () {
	// if the GUI is allowed to be shown....
	if(show) {
		// Create an area to show the content with a scroll bar in it
		GUILayout.BeginArea(Rect (25, 35, 330, 510));
			scrollPosition = GUILayout.BeginScrollView (scrollPosition);
				GUILayout.Label (description);
			GUI.EndScrollView();
			
		GUILayout.EndArea();
		
		// add another area because unity is acting very weird and this
		// is the only way i could make it work *sigh*
		//i know... it makes no sense at all
		GUILayout.BeginArea(Rect (25, 35, 330, 510));
			GUILayout.BeginScrollView (scrollPosition);
			GUI.EndScrollView();
		GUILayout.EndArea();
	}
}

my question is: why did i use this code which makes no sense at all? (at least to me it doesn’t)
and any suggestions on how to fix it?

Here’s a problem:

GUI.EndScrollView();

should be

GUILayout.EndScrollView();

and now i feel dumb lol
thanks a lot :smile: