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
0
Question by trs9556 · Jun 13, 2013 at 01:43 AM · guiscrollviewclamplimitmax

Does GUI.BeginScrollView have a max height?

Hello, I'm using GUI.BeginScrollView to obviously make a scrollable area and it appears that I can't make my scrollable area any larger. I had it set at my screen width for testing purposes and now that I'm populating it my text is now going off screen. When I made the area 4 times the size of the screen width there was no change.

My code:

         //this box defines the overall rectangle. The viewable size (not counting scrolling). So this will position the scroll bars and what not
         Rect box1 = new Rect((screenWidth/3)/2, screenHeight/4 + screenHeight/15, screenWidth/2 + screenWidth/6, screenHeight/2);
         
         //this is the box inside box1. This box defines what can be displayed inside it. So if this is bigger then box1 then we will be able to scroll.
         Rect box2 = new Rect(0, 0, 0, screenWidth*4);
         
         scrollPosition = GUI.BeginScrollView(box1, scrollPosition, box2);
         
         
         float tempHeight = 0;
         GUI.skin.label.normal.textColor = towerStatsLabel1Color;
         GUI.skin.label.font = towerStatsBoldfont;
         GUI.Label(new Rect(0,tempHeight,theContentsWidth, towerStatsLabel1Height), towerStatsLabel1);
         
         GUI.skin.label.normal.textColor = towerStatsLabel2Color;
         GUI.skin.label.font = towerStatsNormalfont;
         tempHeight += towerStatsLabel1Height;
         GUI.Label(new Rect(0,tempHeight,theContentsWidth, towerStatsLabel2Height), towerStatsLabel2);
         
         
         GUI.skin.label.normal.textColor = towerStatsLabel3Color;
         GUI.skin.label.font = towerStatsBoldfont;
         tempHeight += towerStatsLabel2Height;
         GUI.Label(new Rect(0,tempHeight,theContentsWidth, towerStatsLabel3Height), towerStatsLabel3);
         
         GUI.skin.label.normal.textColor = towerStatsLabel4Color;
         GUI.skin.label.font = towerStatsNormalfont;
         tempHeight += towerStatsLabel3Height;
         GUI.Label(new Rect(0,tempHeight,theContentsWidth, towerStatsLabel4Height), towerStatsLabel4);
         
         
         GUI.skin.label.normal.textColor = towerStatsLabel5Color;
         GUI.skin.label.font = towerStatsBoldfont;
         tempHeight += towerStatsLabel4Height;
         GUI.Label(new Rect(0,tempHeight,theContentsWidth, towerStatsLabel5Height), towerStatsLabel5);
         
         GUI.skin.label.normal.textColor = towerStatsLabel6Color;
         GUI.skin.label.font = towerStatsNormalfont;
         tempHeight += towerStatsLabel5Height;
         GUI.Label(new Rect(0,tempHeight,theContentsWidth, towerStatsLabel6Height), towerStatsLabel6);
         
         
         GUI.skin.label.normal.textColor = towerStatsLabel7Color;
         GUI.skin.label.font = towerStatsBoldfont;
         tempHeight += towerStatsLabel6Height;
         GUI.Label(new Rect(0,tempHeight,theContentsWidth, towerStatsLabel7Height), towerStatsLabel7);
         
         GUI.skin.label.normal.textColor = towerStatsLabel8Color;
         GUI.skin.label.font = towerStatsNormalfont;
         tempHeight += towerStatsLabel7Height;
         GUI.Label(new Rect(0,tempHeight,theContentsWidth, towerStatsLabel8Height), towerStatsLabel8);
         
         
         GUI.skin.label.normal.textColor = towerStatsLabel9Color;
         GUI.skin.label.font = towerStatsBoldfont;
         tempHeight += towerStatsLabel8Height;
         GUI.Label(new Rect(0,tempHeight,theContentsWidth, towerStatsLabel9Height), towerStatsLabel9);
         
         GUI.skin.label.normal.textColor = towerStatsLabel10Color;
         GUI.skin.label.font = towerStatsNormalfont;
         tempHeight += towerStatsLabel9Height;
         GUI.Label(new Rect(0,tempHeight,theContentsWidth, towerStatsLabel10Height), towerStatsLabel10);
         
         
         GUI.skin.label.normal.textColor = towerStatsLabel11Color;
         GUI.skin.label.font = towerStatsBoldfont;
         tempHeight += towerStatsLabel10Height;
         GUI.Label(new Rect(0,tempHeight,theContentsWidth, towerStatsLabel11Height), towerStatsLabel11);
         
         GUI.skin.label.normal.textColor = towerStatsLabel12Color;
         GUI.skin.label.font = towerStatsNormalfont;
         tempHeight += towerStatsLabel11Height;
         GUI.Label(new Rect(0,tempHeight,theContentsWidth, towerStatsLabel12Height), towerStatsLabel12);
         
         
         
 
 
         GUI.EndScrollView();

Now if you look at the image, the scroll bar's space show that I have lots of room, but it caps it. I'm unable to scroll any lower then where it is at right now - even though it appears that it will let me. It's acting as if it's clamped or something.

Any thoughts?

alt text

unityscrollviewproblem.png (350.4 kB)
Comment
Add comment
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

1 Reply

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

Answer by trs9556 · Jun 13, 2013 at 03:10 AM

Well I found a band aid fix!

I'm very surprised no one else has had this problem, where the height of a scrollview is capped. Not sure how or why but I figured out how to "work around" this problem.

 //declare your vars
 float scrollX = 0;
 float scrollY = 0;
 private Vector2 scrollPosition = new Vector2(0,1);
 
 
 //in the onGUI:
 scrollPosition = GUI.BeginScrollView(new Rect(0, 0, screenWidth, screenHeight), new Vector2(scrollX,scrollY), new Rect(0, 0, screenWidth * 965, screenHeight * 85));
 scrollX = scrollPosition.x;
 scrollY = scrollPosition.y;
         
 GUI.EndScrollView();
         
 Debug.Log ("Box scrolled @ " + scrollPosition.ToString("F4"));


Notice that instead of getting the x and y from the vector I get it individually from a X var and a Y var. I set those values to the vector, then get the x and y separately from the vector.

From my tests I found that the X coordinate does not have a cap, I can have it 900+ times the width of the screen and it will always scroll. However in my example anything over 3 times the screens height caused the scrollable area to cap in the height direction. This has to be a bug, right?

Comment
Add comment · 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

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

14 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

Related Questions

Show content with scrollbar? 2 Answers

Change Background Color of ScrollView? 2 Answers

Putting Dictionary/List using foreach as buttons in a scroll view? 3 Answers

Unity GUI fitting item list with max size 0 Answers

Two way joint? 1 Answer


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