Questions about controlling multiple conversations individually

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
golden1yaki
Posts: 14
Joined: Tue Dec 08, 2020 6:33 am

Questions about controlling multiple conversations individually

Post by golden1yaki »

Hi!

I'm creating a messenger-like system and running into some problems. What I try to achieve is controlling multiple conversations individually. For instance,

I have started 2 conversations by script (DialogueManager.StartConversation(...)). Both conversations go on simultaneously and player can switch between 2 panels by turning on/off the panel.

- Conversation A (with Dialogue Panel A) [Speaker: Player, Listener: NPC-A]
- Conversation B (with Dialogue Panel B) [Speaker: Player, Listener: NPC-B]

However, I cannot figure out how to specify one conversation and stop it individually. When I call DialogueManager.StopConversation(), all conversations stop.

Is there a way specify conversations or stop conversations individually?

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

Re: Questions about controlling multiple conversations individually

Post by Tony Li »

Hi,

Yes. DialogueManager.instance.activeConversations has information about each conversation. It's a list of ActiveConversationRecords.

When you start a conversation using DialogueManager.StartConversation(), its info will be added as the last ActiveConversationRecord:

Code: Select all

DialogueManager.StartConversation("Foo");
ActiveConversationRecord fooConversation = DialogueManager.instance.activeConversations.Last(); // (Uses System.Linq Last() extension method for shorter code example.)
To stop an individual conversation, call the Close() method on its ConversationController. Example:

Code: Select all

fooConversation.conversationController.Close();
If you're using continue buttons, you can advance a specific conversation by calling its ConversationView's OnContinueConversation method. You also need to specify its dialogue UI:

Code: Select all

var dialogueUI = fooConversation.conversationView.displaySettings.dialogueUI.GetComponent(typeof(IDialogueUI));
fooConversation.conversationView.OnContinueConversation(dialogueUI);
golden1yaki
Posts: 14
Joined: Tue Dec 08, 2020 6:33 am

Re: Questions about controlling multiple conversations individually

Post by golden1yaki »

Thank you for saving my day!

It works perfectly!
User avatar
Tony Li
Posts: 21050
Joined: Thu Jul 18, 2013 1:27 pm

Re: Questions about controlling multiple conversations individually

Post by Tony Li »

Happy to help!
Post Reply