Page 1 of 1

Could DialogueManager.SetLanguage change the running conversation?

Posted: Fri Apr 09, 2021 3:36 am
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)

Re: Could DialogueManager.SetLanguage change the running conversation?

Posted: Fri Apr 09, 2021 6:18 am
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?

Re: Could DialogueManager.SetLanguage change the running conversation?

Posted: Fri Apr 09, 2021 8:32 am
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);
    }
}

Re: Could DialogueManager.SetLanguage change the running conversation?

Posted: Tue Jun 01, 2021 6:17 am
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?

Re: Could DialogueManager.SetLanguage change the running conversation?

Posted: Tue Jun 01, 2021 8:38 am
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.

Re: Could DialogueManager.SetLanguage change the running conversation?

Posted: Tue Jun 01, 2021 8:58 am
by shortlin
Thank you Tony!!It helps me a lot!

Re: Could DialogueManager.SetLanguage change the running conversation?

Posted: Tue Jun 01, 2021 8:59 am
by Tony Li
Glad to help! :-)