Setting localization language via script made the dialogue manager to stop working
Posted: Sat Nov 18, 2023 11:03 am
by farazk86
Hi,
I wrote all my text in English in the conversations tab of Dialogue Manager. I then exported that to my selected languages using the export option outlined here: https://www.pixelcrushers.com/dialogue_ ... ation.html
I added localized text to all the files and then imported them back.
This worked and I can now see localized versions of the conversation for each entry - great success so far..
Now I have a main menu button to select the language for the game, when the flag of that language is clicked it changes the language using
Before the localization, this would bring up the dialogue canvas and the dialogue text would start, now nothing happens, no error shows up either.
Thank you
Re: Setting localization language via script made the dialogue manager to stop working
Posted: Sat Nov 18, 2023 2:07 pm
by Tony Li
Hi,
Localization shouldn't affect whether the conversation starts or not.
Try temporarily setting the Dialogue Manager's Other Settings > Debug Level to Info so you can trace through what's going on. For more info on using Debug Level = Info, please see the Logging & Debugging Tutorial:
Re: Setting localization language via script made the dialogue manager to stop working
Posted: Sat Nov 18, 2023 3:49 pm
by farazk86
Thanks for the response Tony, but it seemed to have fixed itself after a Unity editor restart
The dialogue canvas is now showing but the localized text is still not picked up.
The translations are properly imported as can be seen:
image_2023-11-18_204548173.png (30.58 KiB) Viewed 2903 times
I am using a different asset for localizing the UI, and that changes but in the same function call I am also requesting the language change of DialogueManager.
I am changing the language in the main menu scene and the dialogue canvas is in a different scene, does this matter? Do I have to set the language in every scene where dialogue canvas exists?
Thanks
Re: Setting localization language via script made the dialogue manager to stop working
Posted: Sat Nov 18, 2023 4:08 pm
by Tony Li
Hi,
No, you only need to change it once. Does your Dialogue Manager survive scene changes? This is the default and recommended behavior, but it's possible to change this in the Dialogue Manager's Other Settings section.
Re: Setting localization language via script made the dialogue manager to stop working
Posted: Sat Nov 18, 2023 6:34 pm
by farazk86
My dialogue manager does not exist in the scene in which the localization menu exists.
Dialogue Manager only exists in a single scene where all the story telling happens. Do I have to have the dialogue manager present in the scene for this setting to take effect?
Re: Setting localization language via script made the dialogue manager to stop working
Posted: Sat Nov 18, 2023 7:18 pm
by Tony Li
Hi,
Yes. The Dialogue Manager manages all Dialogue System activity, including calls to DialogueManager.SetLanguage().
Re: Setting localization language via script made the dialogue manager to stop working
Posted: Sat Nov 18, 2023 7:27 pm
by farazk86
Right, understood. I may have missed that in the documentation. Apologies.
Does it have to be the same instance as in should I add a script for DontDestroyOnLoad() on it? I mean does it have to persist through all scenes? as I only have the dialogue manager in one scene, I dont want it to persist in every scene.
I added the dialogue manager prefab in my Main Menu where the localization setting is and set the different language (this is without persistent component) and when I entered the map scene the language was not changed.
Re: Setting localization language via script made the dialogue manager to stop working
Posted: Sat Nov 18, 2023 7:51 pm
by Tony Li
If you put the Dialogue Manager in your main menu scene and keep its Other Settings > Don't Destroy On Load checkbox ticked, does it work correctly?
Re: Setting localization language via script made the dialogue manager to stop working
Posted: Sat Nov 18, 2023 7:57 pm
by farazk86
yes it works now. The dialogue language changed. Thanks
But this is not ideal for me, as I scene dependent events in my dialogue manager and would prefer the old one to persist. Also in some cutscene scenes I have a different dialogue manager with different settings.
Would it be wise to set the language selection to a playerpref in the main menu where the language is changed and then in every scene where I have a dialogue manager I can read the language setting from the player pref and load it there in Awake()?
Or would there be a better way to go about this?
Thanks
Re: Setting localization language via script made the dialogue manager to stop working
Posted: Sat Nov 18, 2023 8:22 pm
by Tony Li
There are a few ways you can do this.
You could allow the main menu scene's Dialogue Manager to persist across all scenes. This won't affect scene-dependent events. (I'm assuming you're using one database, or loading the extra databases using an Extra Databases component.) Then you don't have to worry about it.
Or you can use a different Dialogue Manager in each scene that only survives in that scene. Add a script with an Awake() method like this:
When you set a language, the Dialogue Manager will store that language in the "Language" PlayerPrefs key, so you can use the code above to set it again.