Label size doesn't match text size

So I’m working on some in-game tutorials and tooltips and there’s a problem I can’t seem to solve.

I have a label element in my UI Document that contains description text for a skill. I want the same UI document to be used for different skill tooltips in all the languages we’ll localize the game into, and that means different lengths of text - so I would like to have my tooltip window to match the size of the text.

I’m able to match the size of the window to the size of the label element, but the text in that label itself doesn’t match the set size of the label. Any way to make the label size match the text size?

Here’s how it looks in UI Builder.

Hi,

Try to use this

{
    flex-wrap: wrap;
}

or with UI:

8762743--1188052--upload_2023-1-28_15-9-1.png

If it is not working, make sure the wrap is applied:

8762743--1188055--upload_2023-1-28_15-9-39.png

8762743--1188043--upload_2023-1-28_15-2-44.png
8762743--1188049--upload_2023-1-28_15-8-32.png

Wrapping the text wasn’t the problem. Anyway, I figured it out - turns out you cannot use Position to position the Label (i.e. making it not stick to the border of the box that contains it), you have to use Margin for that. Margin adds space around the text, while Position moves the text from the origin point of the Label without moving or resizing the Label itself.

1 Like