Changing Language Mid-Conversation

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

Changing Language Mid-Conversation

Post by Tony Li »

A dev had a question about changing languages mid-conversation.

Changing languages mid-conversation will change the translation for subsequent lines, but not for the currently-displayed line. To update the currently-displayed line, you will have to manually change the text in DialogueManager.currentConversationState, something like this:
(I haven't tested the code below.)

Code: Select all

DialogueManager.SetLanguage("XX"); // Set to language XX.
var state = DialogueManager.currentConversationState;
state.subtitle.formattedText = FormattedText.Parse(state.subtitle.dialogueEntry.currentDialogueText);
RetranslateResponses(state.npcResponses);
RetranslateResponses(state.pcResponses);
yourDialogueUI.ShowSubtitle(state.subtitle);

void RetranslateResponses(Response[] responses)
{
    foreach (var response in responses)
    {
        response.formattedText = FormattedText.Parse(response.destinationEntry.currentMenuText);
    }
}
Post Reply