Can't get PC messages to log using SMS or Texline templates

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

Can't get PC messages to log using SMS or Texline templates

Post by eeeli »

Hello,

I've been using your Dialogue System in a new project for a little while now, and it's been working great! However, I've run into an issue I can't figure out despite reading through a bunch of older forum posts that appear to want to the same thing.

I'm working on a game that recreates a mobile phone interface, and I'm setting up a messaging system. I thought the SMS template would be perfect. However, I can't get the Player Character messages to save to the log, like the NPC messages are. I have 'Accumulate Text' selected on the PC Message Template. I also tried using a 'Override Display Settings' script with 'Show PC Subtitles During Line' selected.

I also tried turning to the Textline Dialogue example, as that's what I'm going for - the entire text exchange is saved and shown on screen. I downloaded the Textline example, got the example project up and running just fine. However, when I imported the Textline prefab into my project I have the same issue. Everything looks the same, however the Player Character messages aren't being logged.

I don't mind using either template, but I can't get either to behave quite like I'm expecting them to. I wonder if there's some setting I've missed, but I studied the settings in the Textline project and have tried to replicate them exactly.

Thank you so much for any help in advance!
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: Can't get PC messages to log using SMS or Texline templates

Post by eeeli »

Here's a little additional information I didn't mention in the original post that might be helpful.

I am planning on using two different Dialogue UI setups in the project, one to model Phone Calls, and the other to model Messages. I've already implemented the Phone Call UI which is a slightly customized version of the Standard Dialogue UI, but with a few overrides.

Perhaps there's some conflict between having multiple Dialogue UI systems in one scene that I'm unaware of. Regardless, thanks again for any help :)
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: Can't get PC messages to log using SMS or Texline templates

Post by Tony Li »

Hi,

Tick the Dialogue Manager GameObject's Display Settings > Subtitle Settings > Show PC Subtitles During Line, and UNtick Skip PC Subtitle After Response Menu.

If you only want to apply this for conversations with a specific GameObject, add an Override Display Settings component to the GameObject.

If you only want to apply it to a specific conversation, inspect the conversation's properties in the Dialogue Editor and tick Override Display Settings.
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: Can't get PC messages to log using SMS or Texline templates

Post by eeeli »

Okay great, I didn't have the Show PC Subtitles During Line ticked, and that did the trick.

However, like you suggested, I am looking to have this only happen for specific kinds of conversations, and now it's happening for all of them. The break down I'm looking for is:

Phone Calls: No PC Subtitles, just response options shown.
Text Messaging: Response options are shown, and then they're saved to the log as PC Subtitles, like what currently happens in the very handy SMS Template.

I think perhaps I'm not understanding where the Override Display Settings component should go. I originally thought it was supposed to go on the Dialogue System it was overriding (for cases where there are multiple Dialogue UI setups), however I see now you say to put it on the GameObject the dialogue is associated with. Right now it's just a test scene, so I have a dialogue trigger called at start, and I put the Override Display Setting on that object, but it didn't seem to do the trick.

Perhaps I'm running into difficulty because for my set up I'm not planning for conversations to be mapped to specific gameobjects. Instead the player is going to 'call' characters. I've set up the Actors database to have a 'Phone Number' attached to each Actor. Then a player can either 'call' or 'text' and an actor by inputting the phone numbers. The conversations are for the most part going to be triggered through a script which identifies which actor is being called by cross referencing the phone number the player provides with the actor database's phone numbers, and then there will be logic to determine which conversation is entered, based on whether it's a call or text, and ideally then the correct Dialogue system will be used. I have this set up and working for the Phone Calls, and its now that I'm implementing the messaging system I'm running into this issue.

I'm happy to provide more details if that's helpful. Additionally, if you think I ought to be structuring my use of the Dialogue System differently given what I'm ultimately going for, I'm definitely open to suggestions. I tried to read through some past forum threads with folks going for a similar set up, and follow the advice in those threads, but I've also noticed how deep this asset is, and occasionally there are small settings/tweaks to project structures that can make work flows much easier, but might not be immediately noticed by new comers.

Thanks again for your help, I really really appreciate it!
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: Can't get PC messages to log using SMS or Texline templates

Post by Tony Li »

Hi,

There should only be one Dialogue Manager GameObject in the scene.

Whenever a conversation plays, it has up to two primary GameObjects -- the conversation actor and the conversation conversant -- either of which could be null if the Dialogue System can't associate a GameObject with the actor or conversant. For details, see Character GameObject Assignments.

If there is a conversation actor or conversation conversant GameObject, the Dialogue System will check for Override Display Settings or Override Dialogue UI components on them. Somtimes devs will set up an empty GameObject just to put an Override component on it.

If neither of those GameObjects have those components, it will use the Dialogue Manager's current dialogue UI, which is the UI that's assigned to the Dialogue Manager's Dialogue UI field. You can change this UI in C# by calling DialogueManager.UseDialogueUI().

If it's easier for your setup, you could just manually set the dialogue UI and display settings before each conversation. Example:

Code: Select all

public void StartPhoneConversation(string title)
{
    DialogueManager.UseDialogueUI(phoneDialogueUI);
    DialogueManager.displaySettings.subtitleSettings.showPCSubtitlesDuringLine = false;
    DialogueManager.StartConversation(title);
}

public void StartSMSConversation(string title)
{
    DialogueManager.UseDialogueUI(smsDialogueUI);
    DialogueManager.displaySettings.subtitleSettings.showPCSubtitlesDuringLine = true;
    DialogueManager.StartConversation(title);
}
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: Can't get PC messages to log using SMS or Texline templates

Post by eeeli »

Thank you so much!

I think I understand the overall system a bit better now, and manually setting up the dialogue UI and display settings by code before each conversation works great for my setup.

Now that I have the Phone Call and SMS dialogue UI's working nicely I have a follow up question if that's okay.

For the Phone Calls, the conversation is had all the way through to an end point, which works very smoothly with the default setup of the dialogue system.

However, for SMS conversations, I'd ideally like to have it set up like a typical phone: which means there are multiple conversations active at once, and the player can switch between unfinished conversations on the fly. Sometimes responding to a message immediately, or sometimes leaving the dialogue UI, think about it, and return later. I was wondering if there was a way to suspend and return to these conversations, with the idea that the player might be entering & exiting other conversations in the mean time. Thanks again for all your help :)
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: Can't get PC messages to log using SMS or Texline templates

Post by Tony Li »

Take a quick look at the Textline package's Lobby Example. You can download Textline from the Dialogue System Extras page. I don't recommend using Textline itself for your project, but it shows how to set up the SMS-style dialogue UI for multiple SMS conversations. (Its TextlineDialogueUI is virtually identical to the SMSDialogueUI script.)

The steps are to:
  • Tick the SMSDialogueUI's Use Conversation Variable checkbox.
  • Before starting an SMS conversation, set the DS variable "Conversation" to the name of the conversation:

    Code: Select all

    DialogueLua.SetVariable("Conversation", "Adam");
  • Before ending an SMS conversation, call the SMSDialogueUI's OnRecordPersistentData method.
  • To resume an SMS conversation, call SMSDialogueUI's OnApplyPersistentData method. To determine whether an SMS conversation has been started, check if "DialogueLua.DoesVariableExist(YourSMSDialogueUI.currentDialogueEntryRecords)" is true. If so, call OnApplyPersistentData. If not, start the conversation using DialogueManager.StartConversation.
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: Can't get PC messages to log using SMS or Texline templates

Post by eeeli »

Hi, thanks again for your continuing support.

I think I understand the logic happening behind your instructions. However, after trying to implement them, I'm running into an issue.

So, to break it down and to double check I'm doing it right.

- I've ticked "Use Conversation Variable" in the SMSDialogueUI I'm using.

- Just before calling DialogueManager.StartConversation("myConversation"), I'm calling DialogueLua.SetVariable("Conversation", "myConversation"). My understanding is that this creates a Conversation variable in the Lua run-time database that I can then save to and load from using the name as a reference.

- Before ending the conversation I'm calling OnRecordPersistentData() inside of my SMSDialogueUI, then I'm calling OnConversationEnd(). I'm not sure if this is entirely right, but because the conversation doesn't naturally end through going through all the reponses, I thought it might be important to call it.

- Then, when I go to resume the conversation I am checking DialogueLua.DoesVariableExist(MySMSDialogueUI.currentDialogueEntryRecords), then calling myDialogueUI.OnApplyPersistentData().

As a side note, I don't fully understand why I give DialogueLua.DoesVariableExist() MySMSDialogueUI.currentDialogueEntryRecords, instead of the name of the variable I'm looking for, "myConversation", but I assume it feeds it the same information.

However, this is the part where it seems to be breaking down. I can see that DialogueLua.DoestVariableExist(MySMSDialogueUI.currentDialogueEntryRecords) is never true, despite definitely calling DialogueLua.SetVariable("Conversation", "myConversation") each time I start the conversation.

My apologies if I'm missed something simple here! I really appreciate your help, I feel like I'm close to having the Dialogue System setup perfectly for my needs :)
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: Can't get PC messages to log using SMS or Texline templates

Post by Tony Li »

The "Conversation" variable holds the name of the current conversation (e.g., "myConversation").

When you call SMSDialogueUI.OnRecordPersistentData() while a conversation is active, it saves the conversation's log in a variable named "DialogueEntryRecords_<your-conversation>", such as "DialogueEntryRecords_myConversation".

This code will check if a conversation's log has been saved in its corresponding variable, assuming MySMSDialogueUI is a reference to your dialogue UI:

Code: Select all

DialogueManager.UseDialogueUI(MySMSDialogueUI.gameObject);
DialogueLua.SetVariable("Conversation", "myConversation");
if (DialogueLua.DoesVariableExist(MySMSDialogueUI.currentDialogueEntryRecords))
{
    // Log already exists, so resume the conversation:
    MySMSDialogueUI.OnApplyPersistentData();
}
else
{
    // Log doesn't exist, so start the conversation for the first time:
    DialogueManager.StartConversation("myConversation");
}
eeeli
Posts: 49
Joined: Tue Oct 05, 2021 4:54 pm

Re: Can't get PC messages to log using SMS or Texline templates

Post by eeeli »

Hi again. So I've followed all of your steps exactly, and it's unfortunately still not working for me.

Here's the exact code I have written:

Code: Select all

        
        DialogueManager.displaySettings.subtitleSettings.showPCSubtitlesDuringLine = true;
        DialogueManager.UseDialogueUI(smsDialogueUI.gameObject);

        DialogueLua.SetVariable("Conversation", "[TXT]" + actor.Name);
        print(DialogueLua.DoesVariableExist(smsDialogueUI.currentDialogueEntryRecords));

        //Check to see if conversation has been started
        if(DialogueLua.DoesVariableExist(smsDialogueUI.currentDialogueEntryRecords)){
            smsDialogueUI.OnApplyPersistentData();
            print("loading convo");
        }  else{
            DialogueManager.StartConversation("[TXT]"+actor.Name);
            print("starting new convo");
        }

        smsDialogueUI.OpenConversationPanel();
smsDialogueUI is a reference to my lightly customized SMSDialogueUI, the custom bits have to do with how it receives inputs for selecting responses.

This code is called in a function outside of my SMSDialogueUI, which is responsible for setting up the conversations before they happen.

I can each each time I re-enter the conversation with my print line that DialogueLua.DoesVariableExist(smsDialogueUI.currentDialogueEntryRecords) returns false each time, no matter how many times I enter the conversation.

Then I have a button which is responsible for taking the player back to the previous menu, thus ending the conversation. When it's clicked I call:

Code: Select all

smsDialogueUI.OnRecordPersistentData();
I'm not sure if this is helpful, but I thought I'd describe the behavior of the conversation after I reenter it. It always starts with the same line of dialogue coming from the NPC, but then after that each NPC and PC is generated multiple times, one additional time for each time the conversation has been started. So the text log looks something like this after the conversation has been entered twice:

Hello!

Hey!
Hey!

What's up?
What's up?

Oh, you know.
Oh, you know.

I'm not sure if that's relevant information or not.

I'm sorry to get into the weeds here, I really appreciate your help. Any advice on trouble shooting/bug fixing my setup would be very appreciated, and I'm happy to go into more detail on anything that might be relevant/configured incorrectly.
Post Reply