Page 1 of 1

Event to detect when language changes

Posted: Tue Jun 16, 2020 6:23 pm
by Haytam95
Hi!

I'm working on a Menu for a game, and I'm using TextTables and creating some scripts that converts text in (For example) TextMeshPro to the table field value, if match any.

That works okay, the trouble is, that I'd like to make this little scripts subscribe to some kind of Event, to detect when the user changes the language. That way, I would re-retrieve the values of the field with the new language.

Can I subscribe to an event that is fired when the language is changed? Is there such event? (And also, if i'm over complicating creating this scripts let me know!)


Re: Event to detect when language changes

Posted: Tue Jun 16, 2020 7:28 pm
by Tony Li
Hi,

If you make your script a subclass of the Dialogue System's LocalizeUI class, its UpdateText() method will be called whenever the language changes.

In the case of your script, you can just use LocalizeUI directly without having to write any scripts. It localizes TextMeshProUGUI and UI.Text components.

Re: Event to detect when language changes

Posted: Tue Jun 16, 2020 7:48 pm
by Haytam95
Ohh, alright so just by using LocalizeUI it will work (I just tested, worked at once!)

In the future, if I have another UI component that isn't a text or TextMeshPro (Which would be rare, now thinking about it) I should extend from LocalizeUI and then override UpdateText method, right?

Thanks Tony

Re: Event to detect when language changes

Posted: Tue Jun 16, 2020 8:07 pm
by Tony Li
Hi,

Yes. That's all you need to do.