Completing the prior subtitle text with current response?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

Completing the prior subtitle text with current response?

Post by fkkcloud »

Hello,
11111111.png
11111111.png (25.7 KiB) Viewed 379 times
I have something like this above and want to complete the single player subtitle's latter part with the response that I have.'
What is best solution for it?
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Completing the prior subtitle text with current response?

Post by Tony Li »

Hi,

You can define a custom Boolean field for your dialogue entries, such as "AddToNext". In the "I mean..." node, set the field to True.

Then add a script to the Dialogue Manager that has an OnConversationLine method. Something like:

Code: Select all

private string textToAdd = string.Empty;

void OnConversationLine(Subtitle subtitle)
{
    subtitle.formattedText.text = textToAdd + subtitle.formattedText.text;
    textToAdd = Field.LookupBool(subtitle.dialogueEntry.fields, "AddToNext") ? subtitle.formattedText.text : string.Empty;
}
This method will check if AddToNext is true. If so, it will remember the subtitle's text and add it to the next subtitle.
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

Re: Completing the prior subtitle text with current response?

Post by fkkcloud »

Hi,

Is it possible to add it to the previous one?
For instance,

"I mean.." actually stays longer than those 2 responses. After I click on either of that, it will change the previous node which is "I mean..." to "I mean.. you are fine".

Since the "I mean.." node disappear after those 2 responses disappear, it will be much natural for the conversation flow.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Completing the prior subtitle text with current response?

Post by Tony Li »

Here's a small example scene using the script above. It was made in Unity 2020.1.

DS_AddToNextExample_2020-10-20.unitypackage
Post Reply