Unity: TextMeshPro Add Spaces at End of Line

5/22/2020 7:39:05 PM

Set a TextMeshPro text value with Unicode characters and add a new line character.


//get object
var my_text = GameObject.Find("My TMP Text").GetComponent<TMPro.TextMeshProUGUI>();

//add 10 spaces at the end of the line
//doesn't show up in the ui
my_text.text = "something          ";


//add 1 spaces at the end of the line
//DOES show up in the ui
my_text.text = "something\u00A0";


//add 10 spaces at the end of the line
//DOES show up in the ui
my_text.text = "something\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0";