Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by Draco18s · Sep 08, 2011 at 07:05 PM · scrollviewscrolltextareatextbox

Unity Scrolling Textbox

I'm trying to build a GUI scrolling textbox where the content will be of unknown length and will change (but not user editable).

While BeginScrollView is nice, I am forced to determine the scroll height before I build any content, not that there's any way to poll the height of content or to get a TextArea to auto-adjust its height depending on its content.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Ray-Pendergraph · Sep 08, 2011 at 11:08 PM

Use GUILayout.BeginScrollView if you can it's a lot less troublesome. If you can't then the CalcXXXX methods on GUIStyle will help you calculate the area needed by rendered text. I think these only work in OnGUI so this encourages you to recalculate every OnGUI (that's bad) or have a 'calculated' flag to signal recalculation is needed in OnGUI when new text or data model content is set.

Comment
Add comment · Show 4 · 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 Draco18s · Sep 09, 2011 at 03:43 PM 0
Share

That doesn't help. I am using BeginScrollView but I have the issue of not knowing how big to make the scrollable area as the text hasn't even been rendered yet.

avatar image Ray-Pendergraph · Sep 09, 2011 at 07:40 PM 0
Share

Exactly, these methods will precalculate how big the controls need to be to accommodate the text when it is finally rendered but before you render them the first time. Then you can size your components manually accordingly. $$anonymous$$aybe I am missing what you are doing.

avatar image Draco18s · Sep 09, 2011 at 07:45 PM 0
Share

Ah! I missed that it was a GUILayout, not just the GUI. That has (had?) the issue of not allowing me to place it on the screen in absolute coordinates (or rather, relative to the GUI.Window) but someone pointed me at GUI.Group(), so that solved that.

avatar image BerggreenDK · Sep 09, 2011 at 08:16 PM 0
Share

GUILayout.BeginArea has Rect coords, but think of Area as a large rectangle.

avatar image
1

Answer by Draco18s · Sep 09, 2011 at 08:19 PM

This is what I did:

GUI.BeginGroup(Rect(0,395,250,305));

scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(240), GUILayout.Height(275));

GUILayout.Label(descriptString);

GUILayout.EndScrollView();

GUI.EndGroup();

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 BerggreenDK · Sep 09, 2011 at 08:25 PM 0
Share

I wouldnt use GUI combined with GUILayout. If you need to place the Scrollview, use the GUILayout.BeginArea() http://unity3d.com/support/documentation/ScriptReference/GUILayout.BeginArea.html

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

My scrollview doesn't scroll entirely 0 Answers

Scroll Rect doesn't display items Unity 5.6 2 Answers

Scroll A Text Once It Reaches The End Of The Viewport 0 Answers

Unity UI double Scroll Rect handler? 0 Answers

How to have multiple panels react in a single scrollview? 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