How to create line break in yarn spinner?
Anyone have any idea how to create a line break in yarn spinner? I've tried \n and \\n and neither works.
Answer by unity_jSN6Q_iSu5g-0w · Nov 20, 2020 at 05:24 PM
A little late, but here it goes:
when Yarn spinner imports your text to unity the "\n" is not being interpreted as new line but as two characters "\" + "n" wich is why it only prints this out in the text. You have to make your own line feed character to use in yarn for line breaking (i.e. ^) To do that, open DialogUI script of the yarn spinner and on the line 287 use a replace method on the "text" variable, like this:
text = text.Replace('^', '\n');
This replaces your custom yarn character for a new line with "\n" but this time unity will iterpret it as a line feed not as a "\" + "n" as it does when importing from yarn file. Now, when writing your dialogue, use the custom character (i.e "^") to break new line without making yarn skip to the next yarn.line. Took me a few days to find this solution but it works.
No worries, this is still highly relevant. Thank you for this solution. Works great for me.A little late, but here it goes
Answer by Vivien_Lynn · Dec 18, 2020 at 06:49 PM
If you use YarnSpinner with Text Mesh Pro, you can do a line break by typing <br>
. For example:
This is the first line. <br>This is the second line.
Will return this:
This is the first line.
This is the second line.
This will not work correctly with the build in type-writer effect ( DialogueUI.TextSpeed > 0
), because it will generate the command step by step. Meaning that you can see how it types <
then b
and then r
, before the command disappears and the line break happens.