How to end all current conversations?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

How to end all current conversations?

Post by eeeli »

Hello,

I'm running into an issue upon reloading a scene, but the dialogue system continues running the current conversation. There are events the player can trigger that will cause the scene to reload even if they're in the middle of a conversation, and this causes issues in the scene reload because the Dialogue Manager is never destroyed/reloaded so it just tries to finish out the conversation.

I was wondering how I can end all current conversations mid-flow, so I do that before calling the reload. It might be worth mentioning that I have it set up so there might be multiple parallel conversations happening at once.

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

Re: How to end all current conversations?

Post by Tony Li »

Hi,

You can close the conversation controllers in the DialogueManager's activeConversations list. Loop down from the end because they'll remove themselves from the list as they close.

Code: Select all

public void StopAllConversations()
{
    for (int i = DialogueManager.instance.activeConversations.Count - 1; i >= 0; i--)
    {
        DialogueManager.instance.activeConversations[i].conversationController.Close();
    }
}
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: How to end all current conversations?

Post by eeeli »

Brilliant! Thanks :)
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to end all current conversations?

Post by Tony Li »

Happy to help! I'll wrap up that code in a new DialogueManager.StopAllConversations() method in version 2.2.25.
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: How to end all current conversations?

Post by eeeli »

Hi Tony,

Sorry to resurrect this thread. I have a quick follow up question. How should I go about stopping a specific conversation.

The context again, is that there might be multiple conversations running at once (background texting conversations), and the a primary phone-call conversation that can be ended at any given point if the player hangs up the phone.

Is there a way to perhaps record which Dialogue Instance a given conversation is when I start that conversation, so I know which one to stop later on?
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to end all current conversations?

Post by Tony Li »

After you call DialogueManager.StartConversation(), DialogueManager.instance.Conversation will be a reference to that conversatios. DialogueManager.instance.]activeConversations will contain a list of all active conversations. These are ActiveConversationRecords.

Let's say you've recorded the value of DialogueManager.instance.activeConversation after starting a conversation into a variable "myConversationRecord". You can stop that conversation by closing its controller:

Code: Select all

myConversationRecord.conversationController.Close();
Side note: You can get an active conversation's ID like this example:

Code: Select all

ConversationModel model = DialogueManager.instance.activeConversation.conversationModel;
int ID = model.GetConversationID(model.firstState);
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: How to end all current conversations?

Post by eeeli »

Awesome! I think I understand the system, and I have it up and running nicely :)
Post Reply