Best practices in adding dynamic data to conversations

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
alexander
Posts: 10
Joined: Tue Feb 16, 2021 6:43 am

Best practices in adding dynamic data to conversations

Post by alexander »

Hello,

we use the dialogue system in simulated chat sequences in our game. As with every messenger we want to show the dates a message has been send or received. Whether those dates are fictional or authentic, they are a dynamic element we can't add to the conversation database upfront. Is there a way to append such meta information into the stored data when saving a conversation, being able to retrieve it later? Does anybody have suggestions how to accomplish this elegantly?

Thanks in advance.
User avatar
Tony Li
Posts: 22166
Joined: Thu Jul 18, 2013 1:27 pm

Re: Best practices in adding dynamic data to conversations

Post by Tony Li »

Hi,

It's relatively easy to show additional dynamic content as the conversation plays. One way is to use an OnConversationLine method. Example:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    // Prepend current date:
    subtitle.formattedText.text = $"{DateTime.Now}:\n{subtitle.formattedText.text}";
}
Saving it for later reference may be harder.

If you just save the lines of text as they're played, you don't need to do anything special:

Code: Select all

private string transcript;

void OnConversationLine(Subtitle subtitle)
{
    // Prepend current date:
    subtitle.formattedText.text = $"{DateTime.Now}:\n{subtitle.formattedText.text}";
    
    // Add line to transcript:
    transcript += $"\n{subtitle.speakerInfo.Name}\n{subtitle.formattedText.text}";
}
If you're not doing that, please let me know how you're saving conversations. I may be able to suggest something.
Post Reply