otez
November 18, 2020, 3:28pm
1
For example, i have this piece of code.
TMP_Text caption;
string myText = "\tHello there\n\tHow are you?";
caption.text = myText;
If i set text to TMP_Text with “Parse Escape Characters” option on, it won’t parse escape characters in runtime. It parses them when i set this text in editor though.
The “Parse Escape Characters” option only applies to the Text Input Box. It does not affect strings in C#.
In a string you can escape the sequence by using the following:
string myText = “\tHello there\n\tHow are you?”; where both \t are escaped but not the \n.
You can also prefix the string with “@” where the string will be process as literal.
string myText = @“\tHello there\n\tHow are you?”;
1 Like