Page 1 of 1

How to get All Dialogue Entries of a conversation

Posted: Wed Nov 10, 2021 10:28 am
by etsapekis
Via Dialogue Manager, I cannot even get the current dialogue entry; I have to get it through the StandardUISubtitlePanel. I would like to retrieve all relevant info in all the dialogue entries when the conversation starts, so I need a way of getting references to all of the dialogue entries of a conversation. How can I do this? Also, is there not an event I can subscribe to to detect that a new dialogue is displaying? I have to run an update loop checking the current id of the conversation and dialogue entry, but I'd much prefer having an event to subscribe to in code.

Re: How to get All Dialogue Entries of a conversation

Posted: Wed Nov 10, 2021 10:45 am
by Tony Li
Hi,

See Script Messages and Events. Some example code you can put in a script on the Dialogue Manager:

Code: Select all

// When conversation starts, log all dialogue entries:
void OnConversationStart(Transform actor)
{
    var conversation = DialogueManager.masterDatabase.Getconversation(DialogueManager.lastConversationStarted);
    foreach (DialogueEntry entry in conversation.dialogueEntries)
    {
        Debug.Log($"[{entry.id}]: {entry.subtitleText}");
    }
}

// On each line, log info about the line:
void OnConversationLine(Subtitle subtitle)
{
    Debug.Log($"[{subtitle.dialogueEntry.id}] {subtitle.speakerInfo.Name}: {subtitle.formattedText.text}");
    // (Current conversation state is also available in DialogueManager.currentConversationState any 
    // time a conversation is active .)
}

Re: How to get All Dialogue Entries of a conversation

Posted: Wed Nov 10, 2021 1:29 pm
by etsapekis
I'm not seeing how to subscribe to OnConversationLine. It does not seem to be an option for the dialogue manager nor the subtitle panel. I already have conversationStarted without issue, but not the line

Re: How to get All Dialogue Entries of a conversation

Posted: Wed Nov 10, 2021 2:11 pm
by Tony Li
It's not a subscription; it's a message. It's invoked on scripts on the Dialogue Manager GameObject's hierarchy and the participants. (Messages get a bad rap when they're used incorrectly, but they're designed for incidental notifications such as these.)

Re: How to get All Dialogue Entries of a conversation

Posted: Wed Nov 10, 2021 11:23 pm
by etsapekis
Oh, I see.
Followup question. Is it safe to always assume that DialogueEntry.Id is equal to its index in the conversation's list of dialogue entries? or at least that an entry with Id == 0 is always the start node?

Re: How to get All Dialogue Entries of a conversation

Posted: Thu Nov 11, 2021 7:32 am
by Tony Li
Entry ID 0 should always be the <START> node. But there is no guarantee that other nodes' IDs will be the same as their indices in the conversation's dialogueEntries list.