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
11
Question by Morning · Sep 12, 2014 at 01:12 PM · uitext4.6scrollrect

4.6 UI Text rect does not expand automatically

Hello,

I have a window that has a lot of text inside but the text is filled in dynamically. The problem is that the rect of text object does not grow to accommodate the text which makes text scrolling not work.

Am I doing something wrong or is it a bug? Or is that intentional?

I'm using unity 4.6.0b18

Thanks a lot

Comment
Add comment · Show 5
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 HarshadK · Sep 12, 2014 at 01:40 PM 0
Share

I'm a bit confused here as to what you want to say here:

The problem is that the rect of text object does not grow to accommodate the text which makes text scrolling not work.

The way it works is, if the rect of text grows to fit the text then there will be no scrolling and if you want scrolling then the rect should not grow.

Could you specify which one out of these two effects do you want to achieve?

avatar image Morning · Sep 12, 2014 at 03:59 PM 0
Share

$$anonymous$$y hierarchy is like this "Canvas>Panel>Text" Panel has Scroll Rect attached that references Text. When Text's rect size is same as panel or smaller, no scrolling occurs. When Text's rect is bigger than panel, it scrolls as intended. But adding more text does not make Text's rect increase in size, thus if there is too much text to fit in Panel, it will not show but it also won't scroll since Text's rect is not out of Panel's bounds to start scrolling.

When I manually size Text's rect big, it scrolls fine but it isn't dynamic. If there's a lot of text, Text's rect does not increase in size to accommodate said text, thus not triggering scrolling.

avatar image pickle chips · Sep 14, 2014 at 10:02 PM 0
Share

Did you ever find a solution? I'm trying to figure out the same thing right now.

avatar image saviemedia · Nov 24, 2016 at 04:25 AM 0
Share

I have the same issue in Unity 5.5.0f1. It use to work on 5.5.0b3. Did you manage to fix it? Thanks :)

avatar image Cynikal ♦ saviemedia · Nov 24, 2016 at 04:37 AM 0
Share

Answers should be used for answers. Not questions. Please use the comment feature in the future. Thank you.

2 Replies

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

Answer by Ash-Blue · Oct 06, 2014 at 09:14 PM

You will want to use the "content size fitter" component as mentioned by @Morning. Example image included.

alt text


screen shot 2014-10-06 at 2.12.51 pm.png (146.1 kB)
screen shot 2014-10-06 at 2.14.37 pm.png (85.7 kB)
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 knifesk · Jan 08, 2015 at 04:39 PM 0
Share

though the accepted answer may work (i have not checked it)... this answer seems to be the better way to do it...

avatar image
9

Answer by pickle chips · Sep 14, 2014 at 10:26 PM

In case you're still needing this, I Just got this working with this little script that you can attach to the Text object. The Text component luckily has a property called "PreferredHeight" which is just the height of the overflowing text. So set the height of the textbox to the preferred height and boom you're golden.

     RectTransform rt;
     Text txt;
 
     void Start () {
         rt = gameObject.GetComponent<RectTransform>(); // Acessing the RectTransform 
         txt = gameObject.GetComponent<Text>(); // Accessing the text component
     }
 
     void Update () {
         rt.sizeDelta = new Vector2(rt.rect.width, txt.preferredHeight); // Setting the height to equal the height of text
     }

And that's all it takes.

Comment
Add comment · Show 2 · 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 Morning · Sep 15, 2014 at 02:08 PM 2
Share

That works but turns out there is a "content size fitter" component that seems to do the same

avatar image EricJ13 · Jun 22, 2017 at 01:12 PM 0
Share

I prefer pickle chips' method, as the Content Size Fitter caused undesired behavior.

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

8 People are following this question.

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

Related Questions

how to make UI Image inside Scroll Rect (ScrollRect) autoscroll? 1 Answer

Text Preferred Height not expanding even with content size fitter 0 Answers

[Unity 4.6 Beta] Rect Transform Position (New UI System) 7 Answers

Text blurred: uGUI 4.6 9 Answers

Text Color Null Ref 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