Could DialogueManager.SetLanguage change the running conversation?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
shortlin
Posts: 73
Joined: Wed Jun 03, 2020 1:52 am

Could DialogueManager.SetLanguage change the running conversation?

Post by shortlin »

I use DialogueManager.SetLanguage to change the text language.But,When the Dialogue is executing,the running conversation's language would not change(It will be changed next conversation).So if I want to Change the running convesation's language Should I must use a way to find the conversation's id and got this dialogue text's language to change?

Or Maybe My Dialogue System should be update?My version is 2.2.13(Our game has finished all most 90%,so I did not update recently)
shortlin
Posts: 73
Joined: Wed Jun 03, 2020 1:52 am

Re: Could DialogueManager.SetLanguage change the running conversation?

Post by shortlin »

And I Found,If The Dialogue is running,if the name's origin language had ocoured,and then I use DialogueManager.SetLanguage.The Name's Language would not change(restart or start a new conversation would change),Is it normal?
User avatar
Tony Li
Posts: 21721
Joined: Thu Jul 18, 2013 1:27 pm

Re: Could DialogueManager.SetLanguage change the running conversation?

Post by Tony Li »

Hi,

If you change languages while a conversation is running, the next dialogue text should use the new language. But the characters' display names will not change. This is because the Dialogue System caches the display names when the conversation starts. To update the cache after changing languages, use code like this:

Code: Select all

public void UpdateCharacterNames()
{
    DialogueManager.conversationModel.actorInfo.Name = PixelCrushers.DialogueSystem.CharacterInfo.GetLocalizedDisplayNameInDatabase(DialogueManager.conversationModel.actorInfo.nameInDatabase);
    DialogueManager.conversationModel.conversantInfo.Name = PixelCrushers.DialogueSystem.CharacterInfo.GetLocalizedDisplayNameInDatabase(DialogueManager.conversationModel.conversantInfo.nameInDatabase);
}
This method works for the primary actor and conversant. If your conversations involve additional characters, use this method instead:

Code: Select all

public void UpdateCharacterNames()
{
    var conversation = DialogueManager.masterDatabase.GetConversation(DialogueManager.currentConversationState.subtitle.dialogueEntry.conversationID);
    var actorIDs = new HashSet<int>();
    conversation.dialogueEntries.ForEach(entry => actorIDs.Add(entry.ActorID));
    foreach (var actorID in actorIDs)
    {
        var characterInfo = DialogueManager.conversationModel.GetCharacterInfo(actorID);
        characterInfo.Name = PixelCrushers.DialogueSystem.CharacterInfo.GetLocalizedDisplayNameInDatabase(characterInfo.nameInDatabase);
    }
}
shortlin
Posts: 73
Joined: Wed Jun 03, 2020 1:52 am

Re: Could DialogueManager.SetLanguage change the running conversation?

Post by shortlin »

Hi Tony,Sorry to ask question in the article.
I have another question with this situation.
Except I Want to change the normal dialogue text,I also wanted to change the response dialogue text.
So I tried to use DialogueManager.currentConversationState.pcResponses
to get the response array,If when I change language and the conversation has the player choices.But I only could use the response content in the scene to change the text.If the response menu appeared I could change.But before they appeared,I could not change the text.
So are there a way to change the response text before they are created?
User avatar
Tony Li
Posts: 21721
Joined: Thu Jul 18, 2013 1:27 pm

Re: Could DialogueManager.SetLanguage change the running conversation?

Post by Tony Li »

Hi,

If you change the language, it should also change the response menu text.

However, if you change the language while the response menu is visible or the node before the response menu is visible, it won't update the text. To update the text in this case, call DialogueManager.UpdateResponses().

If you need to manually change the text for some reason, you can use an OnConversationResponseMenu() method.
shortlin
Posts: 73
Joined: Wed Jun 03, 2020 1:52 am

Re: Could DialogueManager.SetLanguage change the running conversation?

Post by shortlin »

Thank you Tony!!It helps me a lot!
User avatar
Tony Li
Posts: 21721
Joined: Thu Jul 18, 2013 1:27 pm

Re: Could DialogueManager.SetLanguage change the running conversation?

Post by Tony Li »

Glad to help! :-)
Post Reply