Line breaks "\n" not formatting when string is modified, is there a work around?
So basically I just used text.replace on the text values of some TMP_Text components:
gameObject.GetComponentInChildren<TMP_Text>().text = gameObject.GetComponentInChildren<TMP_Text>().text.Replace("#", quantity.ToString());
gameObject.GetComponentInChildren<TMP_Text>().text = gameObject.GetComponentInChildren<TMP_Text>().text.Replace("$", price.ToString());
Looking via the inspector, the text values are exactly what I want, but in the actual runtime, the string I see is "Sell 9 to \nWinston's \n7"
Is there a way with Unity or Text Mesh Pro for the component to re-format the linebreak? Or is string.Replace() deprecated?
Answer by orangebookair · Feb 21 at 07:09 PM
It took me this long to realize that typing enter is the equivalent of a linebreak but it still works after you use string.replace()
Your answer
Follow this Question
Related Questions
On Trigger Display Text but centered not centered? 1 Answer
Create new text file everytime the game runs 1 Answer
Insert variables into Text / String 1 Answer
Variables In Editor Inspector Strings 1 Answer
Number string to .text returning 0 0 Answers