• 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
4
Question by minibomberman · Aug 26, 2014 at 01:44 PM · gui

New UI.Text rect to fit with text size ?

Long story : I want informations popups on my app, like for example multiple tutorial popups. . . With always the same pattern : scrollable text on the right and image viewer on the left. The fact is that all my texts doesn't have the same size. So the problem is that, if i make the Rect holding my text to fit with one text, it will probably not fit with another text.

So sometime my scrollbar won't got far enough to display all my text. And sometime, the text will be shorter and the scrollbar will go to far and show empty space.

Long story short : Is it possible to adjust the size of the new UI.Text container (Rect) to be exactly what it is needed and not more.

The only problem i imagine when trying to solve this by myself is that there are two possibilities to adjust size, horizontally and vertically. What i want is : given a certain width, adjust Rect Height to display all my text.

Any clue ?

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
26
Best Answer

Answer by digibawb · Aug 26, 2014 at 03:15 PM

Add a ContentSizeFitter component to same object which has the text component. You can then set the Vertical Fit property to PreferredSize for example, to have the Rect for that object automatically be the size required to fit the text.

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 minibomberman · Aug 26, 2014 at 04:02 PM 0
Share

Thanks, that's what i searched.

So i discovered Content Size Fitter. Is it new with 4.6 ?

avatar image digibawb · Aug 26, 2014 at 04:07 PM 0
Share

ContentSizeFitter is part of the new UI system in 4.6, yeah.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Text fields where text will scale along with resolution. 1 Answer

How to group variables in the Inspector? 5 Answers

Start of level Dialogue 2 Answers

Button then instanitates gameobject 1 Answer

Creating GUI 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges