Text scaled + text wrap = uncontrolled text size... or?

Hi there, I have a simple problem I’ve yet to find a (simple) solution for:

I want to set one text label with different strings of text of different lengths inside a frame of a set (scale) size and have that text show the same text size across all strings.

Example:
TextScaled = true
Frame with size scale set to 0.6 x 0.2

A text label set to “String 1”

A text label set to “String 2”

Because “String 2” wraps to a third line, the text SIZE changes. I do not want it to change.

Things I’ve considered/tried:

  • Not setting “TextScaled = true”. Obviously the text size is fixed but then the strings will overflow on different screen sizes e.g. mobile vs desktop
  • Found this post that describes the exact same fundamental issue from 2019 but no one had a solution (the one responder didn’t understand and suggested solutions that don’t work AFAIK)
  • I played around with UIAspectRatioConstraint but that does not do what I need because it does not affect wrapping in any way.
  • I believe I could write code to solve this …but it seems like a complicated solution to a straight forward problem.

I’m hoping there is some simple combination of properties I’m not considering that will solve this. Any help much appreciated!

write less text in 1 string

Seeing the link, what u want to achieve is …
when there are 3 lines of text. the frame becomes bigger??

Im not sure, but I think you dont want that to happen. Cause, lets say a textLabel has all its characters to size “7x5”, meaning theres only room for lets say 100 characters, if the next string to replace the old one contains 150 characters, and keeping exactly the same size, only 100 characters would be visible… Unless, the textLabel grows as already suggested.

Would be taking in count how much room for characters inside that TextLabel, and keep all your strings below that, or grow the gui as more characters are needed

Cause, lets say a textLabel has all its characters to size “7x5”, meaning theres only room for lets say 100 characters, if the next string to replace the old one contains 150 characters, and keeping exactly the same size, only 100 characters would be visible…

Right - I want the text size to be as if there were 150 characters even if there are only 100.

Unless, the textLabel grows as already suggested.

If you’re referring to scripting the text label size, as mentioned, I know I can write code to accommodate this but was hoping there was an easier way. Manually scripting in the textlabel size for every string and testing it across screen sizes is a lot of work for such a simple feature.

Oh nope, I mean, if you go with the scripting approach, first, depends if you want A or B

  • Max room for characters in your text label, lets say all strings should be under 100, and keep the size of all text no matter if its only 50 characters
  • Growing TextLabel, so you could have infinite room for characters same size, and the TextLabel should grow depending on that

Probably you dont need to test intensively on different screen sizes, if you read the device screen size per player, and use the Text size property instead of scale.

Yeah, if you prefer to not script this, you could just use text scaled, and make sure all strings are similar about the amount of characters, even just adding some blank spaces to them, that would be easier, specially with a function that “repairs” all strings in your table by adding invisible characters to fill the “100 characters goal” (not perfect, could cause slight differences per string, but, its easy)

This is exactly what I’m posting about… I am using text scaled and the strings are not the same amount of characters. Due to game requirements, I cannot make them the same amount of characters (using spaces would cause a different, worse layout problem).

As I already said, you can go with the scripting approach, you could use text size instead of scale, and take in count player’s screen size… An “easy fix” for that like enable a couple of properties that fix it all I think its not possible… should be scripted because its considered as a “simple feature” and probably not “lot of work” scriptwise

As I already said in my original post and in each reply, I know I can script a solution. Given there is not a reliable way to know what device a user is on, the only fail safe way to do this is to code up text sizes for screen size ranges. And even then, again, that is not foolproof because any particular string will need to be tested on each of those ranges. And then, if I want a different frame or text of a different size, repeat the whole exercise.

So while it may sound simple, to do it right, in a way that cannot be broken is in fact, not simple via scripting.

Hence, the original question. Appreciate the responses but it sounds like you are not aware of a solution aside from scripting. And there may not be one :slight_smile: But I thought I’d ask.

Yeah, check what device the player is using is more tricky than just checking the size of the screen they are using, and you will get pixels, the real pixels used by the screen in which they are playing, its not about checking their device which could be any, its about checking pixel screen size.

the text cant shrink
alsow the text doesnt get a bigger space

what behaviour would you like the text to have when it is to big??
clip the text and just leave it out. or separate the text into 2??