Line Break with Ink

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Sharzia
Posts: 9
Joined: Thu Nov 28, 2019 8:38 pm

Line Break with Ink

Post by Sharzia »

Hello,

I have the same issue described in this topic but with Ink instead: https://www.pixelcrushers.com/phpbb/vie ... eak#p15121

I tried the same things but I had no luck. I can't go to next the paragraph, it's all in a big wall of text :/
If anyone knows how to fix this, I thank you in advance :/
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Line Break with Ink

Post by Tony Li »

Hi,

Ink is a different beast from all of the other authoring tool integrations. With Ink, the Dialogue System acts as a front-end for Ink's back-end engine. It just displays whatever it receives from Ink.

However, you can still process the text after receiving it from Ink but before it's shown onscreen. Add a script like this to your Dialogue Manager:

ConvertNewlines.cs

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class ConvertNewlines : MonoBehaviour
{
    void OnConversationLine(Subtitle subtitle)
    {
        subtitle.formattedText.text = subtitle.formattedText.text.Replace("\\n", "\n");
    }
}
This will replace any occurrences of the character string "\n" with a line break. If you prefer specifying line breaks with "<br>", change the line to:

Code: Select all

        subtitle.formattedText.text = subtitle.formattedText.text.Replace("br>", "\n");
Sharzia
Posts: 9
Joined: Thu Nov 28, 2019 8:38 pm

Re: Line Break with Ink

Post by Sharzia »

it worked :D
Thank you, It was such a headache for me :x
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Line Break with Ink

Post by Tony Li »

Glad it's working, and happy to help.
Post Reply