Problem with UITextSizeConstraint

I don’t understand how UITextSizeConstraint works because I assume most people use it combined with the TextScale property to make text labels and buttons that look ok (don’t take up the entire text label’s size), but also scale for devices of a variety of dimensions. The problem is by using the max and minimum size, I am effectively removing the functionality of text scaled because I’m limiting the size of the text to pixels, so it will not scale properly past certain dimensions.

Example: Say I want to have a text label where the text in it takes up about 60% of the space of the label’s background. If I set the text scale property to true, the problem occurs where the text appears too large in the box for what I want. So then I use the UITextSizeConstraint to make it fit into my specifications of taking up about 60% of the text box. The problem I run into here is that if I did this on a 1080p monitor, it would look ok, however, if I did this on a 4k monitor or tv, the text constraint would limit the text size so it doesn’t scale properly. I was wondering if there are any good alternatives to use.

The only other options I see is having a smaller text label within a text label which has textscales set to true. This would let me adjust how big I want it relative to the background of the textlabel but the problem here is this would require additional work to be done because in the case of text buttons there would be multiple buttons I have to handle clicks for. The other option I guess would be as the client first initializes I could set the size of all the textlabels/buttons based on the screen dimensions. I like neither of these ideas because they require a lot more work on my end, and seeing as how a ton of games have their text size scale property with different screens I was wondering how you guys do it.

1 Like

Combining it with TextScaled is necessary in most cases. But in it’s main functionality UITextSizeConstraint can set the Maximum size it’s parent’s text can go and same goes with the minimum size.

4 Likes