Localize UI when loading game

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
OscarS
Posts: 17
Joined: Mon Jul 17, 2023 1:47 pm

Localize UI when loading game

Post by OscarS »

Hi,
I had a little problem with the Localize UI component when loading a game. For the items, I have an "Item_Container" which is a prefab. When the game is loaded, a Custom Saver runs a function that instantiates all the Items saved. When I run the game and load a save file, the items instantiate correctly, but the name and description appear with their Text Table name instead of the localized text. But If I go back to the Main menu and load the game again, the items appear correctly with their localized name.

At first, I thought this was a problem about trying to access the table before it was loaded, but this problem persists even if I wait for the scene to be completely loaded to instantiate the items.

Finally, if the player gets a new Item during gameplay the problem is the same. If the game was loaded for the first time, the new items do not have localized text. But if the game was loaded for a second time the items have their localized text correctly.

As always, thanks in advance.
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: Localize UI when loading game

Post by Tony Li »

Hi,

What version of the Dialogue System are you using? Can you back up your project, update to the current version (2.2.42 as of this reply), and check if the issue still persists?

How are you setting the items' names and descriptions?
OscarS
Posts: 17
Joined: Mon Jul 17, 2023 1:47 pm

Re: Localize UI when loading game

Post by OscarS »

Hi Tony,

I updated the DS to 2.2.42, I was using 2.2.38 and the problem still persists. I have a prefab, that includes the Name and Description on TMPRO components. In each TMPRO I added a Localice UI component.
Bug1.png
Bug1.png (5.34 KiB) Viewed 1713 times
Bug2.png
Bug2.png (4.03 KiB) Viewed 1713 times
When I instantiate an Item container on the Menu, I take the name and desc from scriptableobjects, which are referenced through and ID.
Bug3.png
Bug3.png (15.07 KiB) Viewed 1713 times
Finally,on the SO I set the name and desc with the tag on the Text Table.
Bug4.png
Bug4.png (8.48 KiB) Viewed 1713 times

As extra information, I set the debug to info and noticed that when openning the "items tab" this message appears on the console.
Bug5.png
Bug5.png (10.58 KiB) Viewed 1713 times
Bug6.png
Bug6.png (21.78 KiB) Viewed 1713 times
I understand that for some reason, the localize UI of each item container looks for the tag that I set on the container prefab, not on the actual tag of the instantiated item container. And again this is fixed If I go back to main menu and load again, but if I load from within the maingame scene the problem persists.
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: Localize UI when loading game

Post by Tony Li »

Hi,

Try:

Code: Select all

public void LoadItem(ItemsSO item)
{
    itemName.text = DialogueManager.GetLocalizedText(item.itemName);
    itemDescription = DialogueManager.GetLocalizedText(item.itemDescription);
    ...
}
OscarS
Posts: 17
Joined: Mon Jul 17, 2023 1:47 pm

Re: Localize UI when loading game

Post by OscarS »

Hi!
The problem is solved. Thanks!
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: Localize UI when loading game

Post by Tony Li »

Glad to help!
Post Reply