Hi, I am trying to invert the text line order, that is when a long text is written in a UI text, the text component divides it into one or more lines.
How can i invert or change this order of the text so that the last line is being the first one in order as shown in the image below. (My case includes more than two lines of text)
two ways:
1- If you are not using text wrapping, then its just modifying the text.
use string.Split to divide the text.text into lines, swap the array order, then string.Join to get the final text
2- If you rely on Unity UI text wrapping, then you have to write a VertexModifier
In the ModifyVertices function you have to query the text.cachedTextGeneratorForLayout
and get the lines array. (Unity - Scripting API: TextGenerator.lines)
That will tell you in which character each line starts.
With that you can find the vertices belonging to the characters of each line and offset them to the right position.