I have text that is changed dynamically in game. I want new lines to go higher if it’s long enough to need a second line, which you can do with bottom align. However, I get this:
A bunch of text that is
useful.
But I want this:
A bunch
of text that is useful.
Is there a setting that allows text to fill up the lower line before the top? Thanks
You can do it this way…
Use alignment centre/top for the text component.
Rotate the text component by 180 degrees on both it’s x and y axis.
Use an upside down font eg. Download UpsideDown Font - Thousands of fonts to download for free
And reverse the order of the characters in the string.
You can use a function something like this to reverse a string in c#
public string Reverse(string text)
{
if (text == null) return null;
// this was posted by petebob as well
char[] array = text.ToCharArray();
Array.Reverse(array);
return new String(array);
}
Unfortunately I can’t think of an easier way to do it natively in Unity.
String reverse code copied from here c# - Best way to reverse a string - Stack Overflow
You could word-wrap the text yourself. The font will expose the widths of all the characters (see Unity - Scripting API: Font.GetCharacterInfo); insert line breaks at the appropriate locations in your string.
If you’re using a dynamic font, make sure you call Font.RequestCharactersInTexture()
to ensure that the glyphs are in the Font atlas.