Page 1 of 1

Questions about controlling multiple conversations individually

Posted: Wed Feb 03, 2021 9:02 pm
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!

Re: Questions about controlling multiple conversations individually

Posted: Wed Feb 03, 2021 9:25 pm
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);

Re: Questions about controlling multiple conversations individually

Posted: Wed Feb 03, 2021 10:11 pm
by golden1yaki
Thank you for saving my day!

It works perfectly!

Re: Questions about controlling multiple conversations individually

Posted: Thu Feb 04, 2021 9:48 am
by Tony Li
Happy to help!