In my script, I set a variable to be a public string so I can edit it in the editor itself. But I noticed new line characters ( \n ) were not translated as such from the editor to the script and actually displayed the slash and the n.
When I have a private string “This is a\ntest” in a script, it prints
This is a
test
But when it is a public string and set through the editor, it displays as
This is a\ntest
Is there a way to take the literal string in the editor and convert it to the way I’d like the string to operate?
Unfortunately, the only way I’ve found to get newlines to show up when you enter them in the inspector is to type them somewhere else in a text editor or what have you using return carriages and copy/paste the text into the inspector. I’d love to know if there’s a better way, but AFAIK, Unity doesn’t escape text in the editor automatically (You could, of course, do the replacement in Awake/Start, but that’s just as onerous).
I’m not entirely sure what you mean by that, but I’ve gone a different route out of frustration and avoided strings entirely. Thanks either way for the info!
Using alt simply changes my hand tool in unity to a scale tool. Not really able to get that working
I was able to get it to work just fine. Since I presume by the use of “alt+enter” that Horsman is using Windows, I can confirm it also works on Mac using alt+return. Make sure you’re focused on the text field in the Inspector you want to edit and alt+(enter/return) away. Holding alt will trigger changing the hand tool to orbit mode (link), but that won’t affect anything unless you muck about in the Scene view.
I guess I’m just doing something wrong, then. I’ve got the cursor in the textfield in the editor and I’m holding alt and hitting enter and nothing is happening. There doesnt seem to be an alt+key command that works, except for things like alt+tab and alt+ctrl for some more unity camera commands.