Change Dialogues at Runtime

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
stansison
Posts: 10
Joined: Thu Jun 03, 2021 11:44 pm

Change Dialogues at Runtime

Post 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?
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change Dialogues at Runtime

Post 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());
}
stansison
Posts: 10
Joined: Thu Jun 03, 2021 11:44 pm

Re: Change Dialogues at Runtime

Post by stansison »

Thanks for pointing me to the right documentation. This will help!
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change Dialogues at Runtime

Post by Tony Li »

Glad to help! If you have questions about using that method, just let me know.
Post Reply