event to detect when a conversation has ended and it has worked greatly so far!
I have one issue where I would like this event to only trigger when all of the branches of a single conversation finish but currently this event is triggered every time a branch of the conversation ends.
For example, in the attached image, I have four different branches in a single conversation. I would like to have the
Use Dialogue System variables (or SimStatus) to keep track of which branches have been played to the end. When the conversation ends, check if all of the variables (or SimStatus values) indicate that the branches have all ended.
You could do this in the Conditions/Script fields of the last node in each branch, or in a C# script. For example, if you're using SimStatus, you could use C# code similar to this:
DialogueManager.instance.conversationEnded += CheckIfAllBranchesEnded;
...
void CheckIfAllBranchesEnded(Transform other)
{
var conversation = DialogueManager.masterDatabase.GetConversation(DialogueManager.lastConversationID);
foreach (var entry in conversation.dialogueEntries)
{
// If the entry is the end of a branch, check if it's been shown already.
bool isLeaf = entry.outgoingLinks.Count = 0;
var wasDisplayed = DialogueLua.GetSimStatus(entry) == DialogueLua.WasDisplayed;
if (isLeaf && !wasDisplayed)
{
// This branch hasn't ended yet, so exit:
return;
}
}
Debug.Log("YES - ALL BRANCHES ENDED");
}
Conversation conversation = DialogueManager.masterDatabase.GetConversation(DialogueManager.lastConversationID);
foreach (DialogueEntry entry in conversation.dialogueEntries)
{
// If the entry is the end of a branch, check if it's been shown already.
bool isLeaf = entry.outgoingLinks.Count == 0;
bool wasDisplayed = DialogueLua.GetSimStatus(entry) == DialogueLua.WasDisplayed;
//addition
bool isOptional = (entry.Title.Equals("Optional") || entry.Title.Equals("optional"));
//addition and slight adjustment
if (isLeaf && isOptional)
{
continue;
}
else if (isLeaf && !wasDisplayed)
{
// This branch hasn't ended yet, so exit:
return;
}
}
With this small addition, I can mark the last dialogue in the conversation as "Optional" as the last Dialogue's Title and just able to skip checking that!
Thank you so much Tony you have helped me solve a big part of our project !