- Home /
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
Answer by gheeler · Jun 11, 2014 at 11:04 AM
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?
You have to use either
GUI.skin.horizontalScrollbar
or
GUI.skin.verticalScrollbar
or of course you can use your own style if you like.
This is well out of date. This is the old gui system that you should not be using.
It's not out of date. It's just the immediate mode GUI which is still used by the Unity editor and all editor scripts
Answer by ricardo_arango · Apr 15, 2013 at 02:51 AM
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.
Answer by xKroniK13x · Apr 15, 2013 at 03:06 AM
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.
Answer by Rasp1977 · Apr 16, 2013 at 10:29 AM
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 :-)
Answer by Bunny83 · Apr 16, 2013 at 02:04 PM
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 ;)
Actually what I meant was that I just rewrote the interface to scroll the view to touchscreen, so it works like every other android scroll menu.
I have looked through your class and what you do is to wrap everything yourself "very nice if I must say so" and prevent it from using vertical or horizontal scroll bar.
I would like a way to hide the bars in the default scroll view and I find it hard to believe that no one at Unity never had the need to hide it and therefore forgot to add a way to do it.
I have "solved" my problem for the moment, but I really want to use the right official way of doing it.