Resize Text Rect to fit text

Since I am adding items to a scroll list I want them to be as long as required so is there no built in option to make the RectTransform of a Text Mesh Pro UGUI label increase in height as required to fit the text within?
i.e. no overflow, no truncation, just enlarge area!

Edit: OK you can add a Content Size Fitter component but it complains about being in a layout group - a common Unity UI problem

4 Likes

I am not exactly sure what you want to achieve, but this tutorial could get you on the right track.
If you want to follow this tutorial, make sure to tick both boxes for “Control Child Size” (@1:38).

10 Likes

This is not working in 2020.3.20f1 as of the timestamp of my post.

I used this tutorial multiple times already. Just make sure to also tick both boxes for “Control Child Size” @1:38. That should be all that you need to take care of, to have everything working like shown in the video.

1 Like

@Vivien_Lynn , It works with TextMeshPro as well. Thank you!

2 Likes

8511224--1134158--upload_2022-10-13_8-59-4.png

2021.3.4 - not working?

In newer versions of Unity need to check “Control Child Size” width and height

8511329--1134179--upload_2022-10-13_9-50-29.png

4 Likes

This works so well! I have been searching for this and this is the only thing that has worked. I am using it on a Scroll Rect, and I am using code to change what the text says, I personally have to set the min height really high, as it’s acting more as somewhat of a max height. Idk if it said that, or I was just bad and missed it, but this worked very well for me.

1 Like

Still works like a charm :slight_smile: