Page 1 of 1

Best practices in adding dynamic data to conversations

Posted: Mon Mar 01, 2021 2:04 pm
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.

Re: Best practices in adding dynamic data to conversations

Posted: Mon Mar 01, 2021 2:25 pm
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.