Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Sixakoo_ · Feb 05, 2013 at 10:58 AM · guiguilayoutscrollbarbeginscrollview

How to disable horizontal scrollbar in GUILayout scroll view?

I've already read the documentation of the GUILayout.BeginScollView. It is just that I don't understand on how to apply the "alwayShowHorizontal" to false. Here's my code :-

 scrollPosition = GUILayout.BeginScrollView(scrollPosition,GUILayout.Width (Screen.width*30/160), GUILayout.Height(Screen.width*38/160-Screen.height*1/25));

Thank You.

----------Edited to insert image-------- This is the result I get:-

alt text

scrollview.jpg (124.6 kB)
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Gizmoi · Feb 05, 2013 at 12:19 PM 0
Share

Always show horizontal will default to false if you don't set it.

avatar image Sixakoo_ · Feb 05, 2013 at 01:46 PM 0
Share

@Gizmoi, above I uploaded the result that I get. According to my code I didn't set the parameters, didn't I?

avatar image Bunny83 · Feb 05, 2013 at 03:57 PM 1
Share

Do you want to just hide the scrollbar or to prevent the scrollview from scrolling horizontally?

If you want to hide it, just use a custom GUIStyle which doesn't contain an image for the background / thumb...

3 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Baalhug · Feb 04, 2014 at 03:25 PM

If you dont want horizontal scrollbar to show, then your inside rect width must be lower than the rect containing it. This means:

When you call GUI.BeginScrollView you must declare 2 rects (http://docs.unity3d.com/Documentation/ScriptReference/GUI.BeginScrollView.html) The goal of scrollview is to let you draw GUI elements bigger than the area you have to show them, and this is only possible by using scrollbars, as you may understand. So you declare a rect defining the area you have, and another rect defining the real size of your gui content (window, or whatever). Now, if height of the real area is bigger than the display area (change word area by rect, in practise) then a vertical scrollbar will show. If not, you can force it to show by using alwaysShowVertical. The same happens for width.

Conclussion. The only way to avoid horizontal scrollbar shows in scrollview is by defining a rect for the real content equal or smaller than the rect for display. Otherwise, some content would be hidden with no chance to see it.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image krupps · Dec 03, 2021 at 05:16 PM 0
Share

Just uncheck the Horizontal movement. While the Content and child objects works in theory. It doesn't always work depending on the ScrollViews property

avatar image
11

Answer by Ramy-TL · Feb 28, 2017 at 07:51 AM

I use

 scrollPos = GUILayout.BeginScrollView(scrollPos, false, false, GUIStyle.none, GUI.skin.verticalScrollbar);

I hope this helps

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image RealSoftGames · Sep 05, 2017 at 06:34 AM 2
Share

made me sighn in just to upvote this, thanks heaps.

avatar image roulinade RealSoftGames · Sep 22, 2020 at 07:55 PM 1
Share

Same. :) In September 2020 the syntax is

 EditorGUILayout.BeginScrollView(scrollPosition, GUIStyle.none, GUI.skin.verticalScrollbar)
 

But this is still the best answer.

avatar image Darren_Therrien · Oct 13, 2019 at 09:08 PM 0
Share

Very nice. Works like a charm thanks.

avatar image
3

Answer by Gizmoi · Feb 05, 2013 at 03:08 PM

 float width = Screen.width * 30 / 160;
 float height = Screen.width * 38 / 160 - Screen.height * 1 / 25;
 scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, GUILayout.Width(width), GUILayout.Height(height));

That will set alwaysShowHorizontal to false and alwaysShowVertical to be true.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Sixakoo_ · Feb 05, 2013 at 03:31 PM 0
Share

Thanks! Although I now realized that set it to "true" the option only force the scroll bar to appear before content is out of the area. By default(false) it only appears after the content breach the border. So that means that force disabling it is not possible. At least now I know how to use the extended parameter. Thanks again!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Best way to offset GUI element from scrollbar in custom inspector? 0 Answers

GUIlayout scrollbar, Not working well... 1 Answer

scrollbar GUI Skin problem 0 Answers

How to change thickness of ScrollBar of GUILayout ScrollView? 0 Answers

GUILayout.BeginScrollView how to create new row? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges