- Home /
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 ?
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.
Thanks, that's what i searched.
So i discovered Content Size Fitter. Is it new with 4.6 ?
ContentSizeFitter is part of the new UI system in 4.6, yeah.