String Help

Hello i’m using some SerializedFields on my strings. I need to be able to put a new line on my string, what do I need to do to get that? This text is used for a message on the screen so if it’s too long that part of the message just gets cut off and I can only see the first part of the message, that’s why I need a new line.

Generally \r\n should do the trick (escaped carriage feed, new line)

You misunderstood my question I need to be able to enter a new line in the string which i’m editing in the inspector and then I need that to appear in the text.text. What you said didn’t work.

Got it, I was referring to script. In the Inspector, you just manually hit Enter to add a new line.

7949089--1017670--NewLine.png

You can decorate your string field with MultilineAttribute for this:

https://docs.unity3d.com/ScriptReference/MultilineAttribute.html

[SerializeField][Multiline]
private string MyMessage;
1 Like