How to remove/hide GUI scroll bar

I can for the life of me not remove the scroll bar on a scroll view.

I am using GUI.BeginScrollView to create a scroll view and have rewritten it so that it’s a swipe to scroll the view. It works well, now I want to remove the vertical scroll bar.

I have tried setting GUI.skin.verticalScrollbar to other styles but that just throws errors saying it cant find different buttons.

How do I remove the scroll bar from a scroll view?

Best regards
Rasp1977

7 Answers

7

Having just come across this problem the solution is to use GUIStyle.none as stated in other answers but if you only put in one thats just for the horizontal bar. You must put it in twice for the Horizontal and Vertical bars

This is how Im using it

		scrollPos = GUILayout.BeginScrollView (scrollPos, GUIStyle.none, GUIStyle.none, GUILayout.Width (Screen.width), GUILayout.Height (Screen.height - 155));

and what style do we create when we want to view one of the 2 bars?

This is well out of date. This is the old gui system that you should not be using.

You can create a GUI.HorizontalScrollbar which will not have a vertical one.

Also check the parameters you are passing to the function, to make sure you don’t have alwaysShowVertical set to true.

And finally, make sure the height of the content inside the ScrollView is actually smaller than the view size.

I don't want any scroll bar's at all. I have alwaysShowVertical set to false. I need a larger content area then the scroll area so that I can show more than what fits on the screen. It's for Android so the resolution is limited.

Straight outta my coding - the first false is for horizontal bars, second for vertical bars.

var scrollPosition : Vector2;
var width : int;
var height : int;

scrollPosition = GUILayout.BeginScrollView (scrollPosition, false, false, GUILayout.Width(width), GUILayout.Height(height));

Setting alwaysShowHorizontal and alwaysShowVertical to false will not remove them if the content area is larger than the scroll area. Setting them to true will just show them even if they are not needed.

I have worked around it in a very ugly manor that only works because I use the entire screen for the scroll area.

I have set the scroll area to be larger than the screen so that vertical scroll bar is drawn outside the screen.

This is stupid and I hate it. So if anyone knows of a way to disable the scrollbars or hide them. Please let me know.

I am using Unity 3.5, so preferably something that works with that version.

I found this on the forum that may help.http://forum.unity3d.com/threads/29605-Hide-BeginScrollView-scrollbars

Thx for the link. I had already tried all the suggestions on the page, except the GUIX class. I am reluctant to use it as I am trying to learn how everything works, so want to write it myself. I know i know, re-inventing the wheel and stuff like that :-)

Maybe this might help? I’ve written this little helper some time ago bacause someone already was in need of hiding the scrollbars ;). I’m a bit confused, when you said you’ve rewritten the ScrollView, why have you implemented the scrollbars? Did you mean you have “wrapped” GUI.BeginScrollView?

I’ve written a wrapper class for BeginScrollView that works with touch input as well, however the class is part of my menu system which i can’t publish :wink:

To hide the GUI Scrollbar you have to disable the texture in a GUISkin. The reason GUIStyle doesn’t work is because it doesn’t have settings for a scrollbar in there. Also make sure to put your scrollview function AFTER GUI.skin = skin.

This is the correct answer because I couldn’t figure it out for the life of me…

GUI.BeginScrollView(scrollViewPos, viewPos, scrollViewRect, skin.horizontalScrollbar, GUIStyle.none);

This will hide your horizontal scrollbar. Should help.

Thank you, works fine!