I was wondering, is it possible to make a simple line break in a GUI Label?
Because I have a fairly long string that is being written to the screen, and I would rather it to be split to a second line rather than stretch across the whole screen…
In java, javascript, C, C++, C#, and similar languages, you need to use an escape character to display certain characters such as new line or have " show up inside a string literal.
They are called escape characters because they “escape” from their normal useage.
All escape characters start with a \ to tell the compiler that the next character should be interpreted differently than normal.
Here are some common ones:
New line
Tab
\v Vertical Tab
\b Backspace
\r Carriage return
\f Formfeed
\\ Backslash
\' Single quotation mark
\" Double quotation mark
\d Octal
\xd Hexadecimal
\ud Unicode character
There is another solution for this:
string a = “String you want to get from somewhere with
"
a.Replace(”
", "
");
This way Unity gets "
" as a line break. Not my solution but I can’t remember where I have seen it.
Ok, i’m trying to load text, stored in public string, to Text on UI.
How should i wrap this text then inputting it in this string from Inspector?
Just adding "
" or "
" doesn’t work for me. It’s just shows text as is.
If i copy text with “enters” from Notepad, it shows only text before first “enter”.