Adjust text height of Unity 4.6 UI according to content

I am new to the only newest interface. What I know about the text element of the user interface, we can wrap the text in horizontal borders, but if it comes to the next line, then it overflows or is cut off. If it matches the height, the font size is reduced. I want to adjust the height of the text area in accordance with the contents contained in it, without affecting the font size inside.

I will have many text elements as children of the parent panel, the panel itself will be a child in a scrollable container. Therefore, I need to calculate the height of all children in order to adjust the height of the parent panel.

How do I achieve this?

+7
c # text unity3d
source share
2 answers

Add the Content Size Fitter component to Text and set its Vertical Fit to PreferredSize .

I wrote a blog so that people can find it useful, knowing how I used this component to create dynamic lists. http://mobile.folio3.com/creating-dynamic-scrollable-lists-with-new-unity-canvas-ui/

+9
source share

You can use the "Best Fit" option in the script text in the text element of the user interface. And set the value of Min size and Max size according to your needs.

0
source share

All Articles