Changing Language Mid-Conversation
Posted: Mon Jun 01, 2020 8:16 am
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.)
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);
}
}