vertical scroll bar only

i have this code from unity reference manual. what i’m trying to do is put buttons and scroll it using only vertical scroll bar, how can i remove the horizontal scroll from here?

// The position on of the scrolling viewport
var scrollPosition : Vector2 = Vector2.zero;

function OnGUI () {
    // An absolute-positioned example: We make a scrollview that has a really large client
    // rect and put it in a small rect on the screen.
    scrollPosition = GUI.BeginScrollView (Rect (10,300,100,100),
        scrollPosition, Rect (0, 0, 220, 200));
    
    // Make four buttons - one in each corner. The coordinate system is defined
    // by the last parameter to BeginScrollView.
    GUI.Button (Rect (0,0,100,20), "Top-left");
    
    GUI.Button (Rect (0,180,100,20), "Bottom-left");
  
    // End the scroll view that we began above.
    GUI.EndScrollView ();
}

1 Answer

1

This is what I use for my GUI scrolling. If you use wordWrap = true. your text will not allow horizontal scrolling. I hope this is what you mean.

GUILayout.BeginArea (new Rect(10, 10, Screen.width-100, Screen.height-100));
		
			scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(320), GUILayout.Height(250));
	
	        GUI.skin.box.wordWrap = true; 
			
			GUILayout.Box(getWayPointText, myStyle);
	        
	        GUILayout.EndScrollView();
			
			GUILayout.EndArea();