Page 1 of 1

Change Dialogues at Runtime

Posted: Mon Jun 07, 2021 9:56 am
by stansison
Hi Tony,

I’m using a conversation as a template for a type of encounter where the content of the conversation is changed by script.

I used this piece of code:
Conversation conversation = database.GetConversation(conversationName);
DialogueEntry dialogueEntry = conversation.GetDialogueEntry(“nameID");
dialogueEntry.currentDialogueText = “Text Value";

While it works before the conversation is called, the values aren’t changed while the conversation is active. How would I go about changing the value of dialogue entries that’s already loaded?

Re: Change Dialogues at Runtime

Posted: Mon Jun 07, 2021 10:56 am
by Tony Li
Hi,

You can use an OnConversationLine() method. For example, if you add this method to a script on the Dialogue Manager GameObject, it will replace "{TIME}" with the current system time:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    // A Subtitle is a line of dialogue that's about to be shown in the UI, and its corresponding sequence.
    // Here, we replace {TIME} with the system time:
    subtitle.formattedText.text = subtitle.formattedText.text.Replace("{TIME}", System.DateTime.Now.ToString());
}

Re: Change Dialogues at Runtime

Posted: Tue Jun 08, 2021 12:48 am
by stansison
Thanks for pointing me to the right documentation. This will help!

Re: Change Dialogues at Runtime

Posted: Tue Jun 08, 2021 8:07 am
by Tony Li
Glad to help! If you have questions about using that method, just let me know.