multiple Textline Dialog UI in a scene

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: multiple Textline Dialog UI in a scene

Post by Tony Li »

If you call the Close() method of a specific TextlineDialogueUI component, it should only close that dialogue UI.

However, if you want to stop the conversation early, and not just close its dialogue UI, you'll want to do something slightly different.

When you start a conversation, the Dialogue System adds an ActiveConversationRecord object to the DialogueManager.instance.activeConversations list. The most recently-started conversation is at the end of the list. So maybe you'd want to record it like this:

Code: Select all

using System.Linq;
...
DialogueManager.StartConversation("Some Conversation");
var thisConversationRecord = DialogueManager.instance.activeConversations.Last();
The ActiveConversationRecord has a conversationController. If you call its Close() method, it will fully stop the entire conversation and close the associated dialogueUI:

Code: Select all

thisConversationRecord.conversationController.Close();
Tetralogia
Posts: 45
Joined: Wed Jan 09, 2019 7:49 am

Re: multiple Textline Dialog UI in a scene

Post by Tetralogia »

Whether I use base.Close() or thisConversationRecord.conversationController.Close(), the result is the same. I may be doing something wrong though.

I have two simultaneous conversations :

Image

and when the last entry of the second conversation (on the right) is reached, it closes its dialog UI, but it also seems to be erasing the previous lines in the first conversation :

Image
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: multiple Textline Dialog UI in a scene

Post by Tony Li »

Hi,

Can you please compare it to this example scene:

DS_Test2TextlineUIs_2019-12-06.unitypackage

You can play each conversation to the end, or you can click the "Cancel A Conversation" button to cancel one of them. The other one should stay visible and intact.
Tetralogia
Posts: 45
Joined: Wed Jan 09, 2019 7:49 am

Re: multiple Textline Dialog UI in a scene

Post by Tetralogia »

Hi Tony!

Thanks to your example I found what I was doing wrong in my project: all my Textline Dialogue UIs were in the same canvas. I should have thought about that.

Thanks a lot for your example scene!
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: multiple Textline Dialog UI in a scene

Post by Tony Li »

Hi,

You can make a subclass of TextlineDialogueUI and add a method to clear the content:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem.Extras;
public class CustomTextlineDialogueUI : TextlineDialogueUI
{
        public void ClearCurrentContent()
        {
            records.Clear();
            DestroyInstantiatedMessages();
        }
}
Then call ClearCurrentContent() when you want to clear the content to reuse the UI without closing it.
Tetralogia
Posts: 45
Joined: Wed Jan 09, 2019 7:49 am

Re: multiple Textline Dialog UI in a scene

Post by Tetralogia »

Ok nice! Thanks :)
Post Reply