EditorWindow: Scrollview

Hi,

I’m trying to create a custom editor window but i’m having some problems. My width and height scroll bar has a small wiggle room between values (even if there is no content) needed to extend to them.

Also, when there is too much content and I actually need it to scroll. It stays the same.

Thanks in advance!

[33212-unityimage.png*_|33212] an image of what I mean, and here’s the script:

Vector2 scrollPos;

	void OnGUI () {

			scrollPos = EditorGUILayout.BeginScrollView (scrollPos,
			                                             true,
			                                             false,
			                                             GUILayout.Width(Screen.width ),
			                                             GUILayout.Height(Screen.height - 20));

			int posx = 20;

			for (int i = 0; i < asm.mylist.Length; i++) {
			
				GUILayout.BeginArea(new Rect(posx, 20, 60, Screen.height - 80 ));

				asm.mylist _.volume = GUILayout.VerticalSlider(asm.mylist *.volume, 0, 1);*_

_ EditorGUILayout.LabelField (asm.mylist .gameObject.name);_

* GUILayout.EndArea();*

* posx += 70;*

* }*

* EditorGUILayout.EndScrollView();*

* }*
_*

You are doing lot of hand computing that is wrong in some way. But I was unable to find what exactly is wrong. But you can rewrite your script to let unity handle all sizes for you automaticlly.

Yuor script would look like

	Vector2 scrollPos;

    void OnGUI () {
		
		scrollPos = EditorGUILayout.BeginScrollView (scrollPos,
		                                             false,
		                                             false);

		//vertical space
		GUILayout.Space(20);
		
		GUILayout.BeginHorizontal();

		for (int i = 0; i < asm.mylist.Length; i++) {

			//in horizontal layout this is horizontal space
			GUILayout.Space(20);

			//Eqivalent of Begin area, but you only care about width, rest is automaticlly compute, so you do not need "posx"
			GUILayout.BeginVertical(GUILayout.Width(70));

			asm.mylist _.volume = GUILayout.VerticalSlider(asm.mylist *.volume, 0, 1);*_

_ EditorGUILayout.LabelField (asm.mylist .gameObject.name);_

* GUILayout.EndVertical();*

}

* GUILayout.EndHorizontal();*

* EditorGUILayout.EndScrollView();*
}