How Can I Refresh UI Language After Change Language?

Announcements, support questions, and discussion for the Dialogue System.
elektronische
Posts: 9
Joined: Mon Dec 03, 2018 4:31 pm

Re: How Can I Refresh UI Language After Change Language?

Post by elektronische »

Tony Li wrote: Mon Mar 27, 2023 6:31 pm You could tell the subtitle panel to update its content:

Code: Select all

var subtitle = DialogueManager.currentConversationState.subtitle;
subtitle.formattedText = FormattedText.Parse(subtitle.dialogueEntry.currentDialogueText);
DialogueManager.standardDialogueUI.ShowSubtitle(subtitle);
It works perfect, thanks!
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: How Can I Refresh UI Language After Change Language?

Post by Tony Li »

Glad to help!
elektronische
Posts: 9
Joined: Mon Dec 03, 2018 4:31 pm

Re: How Can I Refresh UI Language After Change Language?

Post by elektronische »

Tony Li wrote: Mon Mar 27, 2023 6:31 pm You could tell the subtitle panel to update its content:

Code: Select all

var subtitle = DialogueManager.currentConversationState.subtitle;
subtitle.formattedText = FormattedText.Parse(subtitle.dialogueEntry.currentDialogueText);
DialogueManager.standardDialogueUI.ShowSubtitle(subtitle);
Thanks, it works properly :D

Do you know if there is something similar that I can use to update the response texts without using DialogueManager.UpdateResponses? Specifically, I would like to update the button texts when the response panel is open.
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: How Can I Refresh UI Language After Change Language?

Post by Tony Li »

If you don't want to use DialogueManager.UpdateResponses() to re-evaluate conditions and re-process the dialogue entry text, you can just loop through the menu's instantiatedButtons list -- or the buttons list if you're using predesigned buttons instead of the Button Template. Example:

Code: Select all

// Apply italics to all response button text:
var menuPanel = DialogueManager.standardDialogueUI.conversationUIElements.defaultMenuPanel;
foreach (var buttonGO in menuPanel.instantiatedButtons)
{
    var button = buttonGO.GetComponent<StandardUIResponseButton>();
    button.label.text = $"<i>{button.label.text}</i>";
}
forrestuv
Posts: 64
Joined: Tue Nov 06, 2018 11:28 am

Re: How Can I Refresh UI Language After Change Language?

Post by forrestuv »

elektronische wrote: Mon Mar 27, 2023 4:55 pm
Tony Li wrote: Mon Mar 27, 2023 4:30 pm Hi,

If you're showing a subtitle, you can replay the same dialogue entry:

Code: Select all

var state = DialogueManager.converationModel.GetState(DialogueManager.currentConversationState.subtitle.dialogueEntry);
DialogueManager.conversationController.GotoState(state);
If you're showing a response menu, just call DialogueManager.UpdateResponses().
Thanks for the quick response! :D

Is this the only way? I ask because besides the subtitles, I also use sequences in the dialogue nodes that trigger other things like sounds, animations, etc. So it doesn't seem very efficient to replay the entire dialogue node just to update the subtitles' language.
How to know if I'm displaying responses or a dialogue subtitle?
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: How Can I Refresh UI Language After Change Language?

Post by Tony Li »

Hi,

You can check if the dialogue UI's menu panel is open:

Code: Select all

bool isShowingMenu = DialogueManager.standardDialogueUI.conversationUIElements.defaultMenuPanel.isOpen;
Post Reply