- Home /
C# \n turns into /n
I've been trying to find out how to break to a new line. I've had \n work in a project before now, but for some reason, using Unity 5 it's been 'corrected' into /n
Input:
"Text." +
"\nMoreText."
Output: Text./nMoreText.
I tried using an inputfield, thinking that I was doing something wrong, but now I have no idea.
I don't remember exactly but I think as a workaround you can use:
string test = "Test." + "/n$$anonymous$$oreText.";
test.Replace("/n", "\n");
and the line break works.
I get a 'does not exist in the current context' error when trying to use Replace
'/' is the correct way, '\' is the wrong way.
A quick Google search shows this the correct way. Use your choosen text editor to do a replace all. Whether Unity allowed it before or not and what changed, I do not know.
Ok, but it isn't changing it in the code, it's changing it in the text field.
Secondly it's simply displaying "/n" and not adding the new line that I want it to.
"/n" in the code I posted is just a place holder, you could use anything you want. I found out that doing a "Replace" with "\n" works but writing it in code directly when assigning a string doesn't. I don't know why it's like this or why it's not working for you. In my code reading text from a xml-file and replacing "/n" with "\n" is doing the trick. Sorry I couldn't help you.
Your answer
Follow this Question
Related Questions
Is there a notepad-like (preferably a notepad++-like) in-game text editor for use in Unity5? 0 Answers
Is it possible to change the default caret in an InputField? 1 Answer
is there any way to use 'ə' letter in input field? 0 Answers
Unity 5 UI InputField unicode typing 0 Answers
Holotoolkit on screen keyboard won't open,Hololens on-screen keyboard won't open 1 Answer