How Can I Refresh UI Language After Change Language?
-
- Posts: 29
- Joined: Sat Jan 02, 2021 4:27 pm
Re: How Can I Refresh UI Language After Change Language?
I just tried with new canvas and I added 'UI Localization Manager.cs' and it works!
I think I have a problem with my Dialogue Manager. I have only 1 UILocalizationmanager.cs but it doesn't work.
I think I have a problem with my Dialogue Manager. I have only 1 UILocalizationmanager.cs but it doesn't work.
Re: How Can I Refresh UI Language After Change Language?
Hi,
That should be fine. The UILocalizationManager can be anywhere; it doesn't have to be on the Dialogue Manager.
That should be fine. The UILocalizationManager can be anywhere; it doesn't have to be on the Dialogue Manager.
-
- Posts: 29
- Joined: Sat Jan 02, 2021 4:27 pm
Re: How Can I Refresh UI Language After Change Language?
I found a problem.
I was looking at code
public void UpdateUIs(string language)
{
m_currentLanguage = language;
if (saveLanguageInPlayerPrefs)
{
if (!string.IsNullOrEmpty(currentLanguagePlayerPrefsKey))
{
PlayerPrefs.SetString(currentLanguagePlayerPrefsKey, language);
}
}
var localizeUIs = m_alsoUpdateInactiveLocalizeUI
? GameObjectUtility.FindObjectsOfTypeAlsoInactive<LocalizeUI>()
: FindObjectsOfType<LocalizeUI>();
for (int i = 0; i < localizeUIs.Length; i++)
{
localizeUIs.UpdateText();
}
}
and I just turned off "Also Update Inactive Localize UI" and it works well.
I don't know why this happened.
I was looking at code
public void UpdateUIs(string language)
{
m_currentLanguage = language;
if (saveLanguageInPlayerPrefs)
{
if (!string.IsNullOrEmpty(currentLanguagePlayerPrefsKey))
{
PlayerPrefs.SetString(currentLanguagePlayerPrefsKey, language);
}
}
var localizeUIs = m_alsoUpdateInactiveLocalizeUI
? GameObjectUtility.FindObjectsOfTypeAlsoInactive<LocalizeUI>()
: FindObjectsOfType<LocalizeUI>();
for (int i = 0; i < localizeUIs.Length; i++)
{
localizeUIs.UpdateText();
}
}
and I just turned off "Also Update Inactive Localize UI" and it works well.
I don't know why this happened.
Re: How Can I Refresh UI Language After Change Language?
Hi,
I'll investigate that.
I'll investigate that.
-
- Posts: 29
- Joined: Sat Jan 02, 2021 4:27 pm
Re: How Can I Refresh UI Language After Change Language?
Thank you.
Please tell me if there is a problem.
Please tell me if there is a problem.
Re: How Can I Refresh UI Language After Change Language?
I've confirmed that m_alsoUpdateInactiveLocalizeUI works correctly in a test scene. Can you send a reproduction project to tony (at) pixelcrushers.com?
-
- Posts: 9
- Joined: Mon Dec 03, 2018 4:31 pm
Re: How Can I Refresh UI Language After Change Language?
Hi, I have a question about the same topic. I'm using the method DialogueManager.Instance.SetLanguage to set the language when the user changes it from the options menu. This works correctly, but if a dialogue is active, the language does not change until the dialogue node ends and moves to the next one. Is there any way to make that UI update immediately? So that as soon as the player returns from the options menu, the subtitle language is already updated? Thank you!
Re: How Can I Refresh UI Language After Change Language?
Hi,
If you're showing a subtitle, you can replay the same dialogue entry:
If you're showing a response menu, just call DialogueManager.UpdateResponses().
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);
-
- Posts: 9
- Joined: Mon Dec 03, 2018 4:31 pm
Re: How Can I Refresh UI Language After Change Language?
Thanks for the quick response!Tony Li wrote: ↑Mon Mar 27, 2023 4:30 pm Hi,
If you're showing a subtitle, you can replay the same dialogue entry:
If you're showing a response menu, just call DialogueManager.UpdateResponses().Code: Select all
var state = DialogueManager.converationModel.GetState(DialogueManager.currentConversationState.subtitle.dialogueEntry); DialogueManager.conversationController.GotoState(state);
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.
Re: How Can I Refresh UI Language After Change Language?
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);