messaging-app-like UI

Announcements, support questions, and discussion for the Dialogue System.
Tetralogia
Posts: 45
Joined: Wed Jan 09, 2019 7:49 am

Re: messaging-app-like UI

Post by Tetralogia »

It's working, thanks a lot :)
Tetralogia
Posts: 45
Joined: Wed Jan 09, 2019 7:49 am

Re: messaging-app-like UI

Post by Tetralogia »

How would I go about setting a subtitle color for each actor? I'm using a custom script for now but it's not satisfying to me. I've tried using DialogueActor.cs and ActorSubtitleColor.cs but it's not clear to me if they work without a Dialog System Trigger.

I'm opening conversations with custom lines you gave me, that I call from buttons' OnClick() :

Code: Select all

if (DialogueManager.ConversationHasValidEntry("My Conversation")) {
    DialogueManager.StartConversation("My Conversation");
}
else {
    DialogueManager.dialogueUI.Open();
}
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: messaging-app-like UI

Post by Tony Li »

Hi,

One of these requirements must be met:
  • Specify GameObjects with DialogueManager.StartConversation:

    Code: Select all

    DialogueManager.StartConversation("My Conversation", player, NPC);
    so it knows what GameObject to look for ActorSubtitleColor components on, or
  • Use a DialogueActor component and make the GameObject name match the actor name in the dialogue database, or select the actor from the DialogueActor's dropdown.
sentientplay
Posts: 1
Joined: Mon Jan 21, 2019 11:39 am

Re: messaging-app-like UI

Post by sentientplay »

Tony, question:
If I want to use the standard UI but also have one Textline-style panel, is there a recommended way to do that?
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: messaging-app-like UI

Post by Tony Li »

Did you also ask on the Unity forum? I'll copy my reply here. If this isn't the type of mix you're looking for, let me know. If you only need to show one or the other at any given time, you can use an Override Dialogue UI instead.

---

It's easy to show different views for different actors with the Standard Dialogue UI. Add different subtitle panels to the dialogue UI, add a Dialogue Actor component to each actor, and specify which subtitle panel to use for that actor.

Doing this with the Textline Dialogue UI is a little more complicated because it overrides the Standard Dialogue UI's default behavior. You'll need to make a subclass of TextlineDialogueUI that overrides the ShowSubtitle() and HideSubtitle() methods. When you want to show a subtitle with the original StandardDialogueUI methods, use the same code as in the StandardDialogueUI's version. Here's an (untested) example. It's not a complete script. It's just meant to convey the approach.

Code: Select all

public class CustomDialogueUI : TextlineDialogueUI
{
    public override void ShowSubtitle(Subtitle subtitle)
    {
        if (/* your condition to decide to use textline */)
        {
            base.ShowSubtitle(subtitle); // Show using textline.
        }
        else
        { // Show using StandardDialogueUI:
            conversationUIElements.standardMenuControls.Close();
            conversationUIElements.standardSubtitleControls.ShowSubtitle(subtitle);
        }
    }
 
    public override void HideSubtitle(Subtitle subtitle)
    {
        if (/* your condition to decide to use textline */)
        {
            conversationUIElements.standardSubtitleControls.HideSubtitle(subtitle);
        }
    }
Tetralogia
Posts: 45
Joined: Wed Jan 09, 2019 7:49 am

Re: messaging-app-like UI

Post by Tetralogia »

Hi Tony,

Sorry I thought I had replied to your last post, thanks for the help with the DialogueActor and ActorSubtitleColor components :)
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: messaging-app-like UI

Post by Tony Li »

Glad to help!
Tetralogia
Posts: 45
Joined: Wed Jan 09, 2019 7:49 am

Re: messaging-app-like UI

Post by Tetralogia »

Hi,

is there a way to keep track of what is the last played node in a conversation? What I'd like to do is show a preview of that in the interface, such as :

Image

and change it dynamically by script.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: messaging-app-like UI

Post by Tony Li »

That's a feature that I plan to add to the next release of the Textline template, along with in-game timestamps on messages.

Since it's not available yet, you'll need to implement it yourself. But it's not too hard.

Each conversation's history is stored in a Dialogue System variable named "DialogueEntryRecords_conversation" where conversation is the conversation title. The format is X;A;B;A;B;... where X is the number of entries in the history, and A;B is an entry's conversation ID and entry ID.

So you just need to show the last A;B. Here's some example code:

Code: Select all

// Get the last entry for conversation K:
string history = DialogueLua.GetVariable("DialogueEntryRecords_K").asString;
string[] fields = history.Split(';');
int conversationID = Tools.StringToInt(fields[fields.Length - 2]);
int entryID = Tools.StringToInt(fields[fields.Length - 1]);
DialogueEntry entry = DialogueManager.masterDatabase.GetDialogueEntry(conversationID, entryID);
Debug.Log("Last entry is: " + entry.DialogueText);
Tetralogia
Posts: 45
Joined: Wed Jan 09, 2019 7:49 am

Re: messaging-app-like UI

Post by Tetralogia »

Ok so how should I implement this method?

If I call it when closing the conversation, it just prints : "Last entry is : ". (I use OnRecordsPersistentData() when closing).
If I reopen the conversation and close it again I get the error "Object reference not set to an instance of and object" on this line :

Code: Select all

Debug.Log("Last entry is: " + entry.DialogueText);
I've tried printing the entry.id and it prints : "Last entry is : 0" and then again if I reopen the conversation and reclose it, I get the same error.
Post Reply