#Here's the error, the text on my UI

1 messages ยท Page 1 of 1 (latest)

pearl ocean
#

when are you assigning dailyRoutineLocalizedString? I don't see it anywhere

subtle lodge
pearl ocean
#

no, you're already accessing properties inside that object without ever assiging anything to it

subtle lodge
#

oh

pearl ocean
#

you either need to create a new instance of it during runtime or assign it through the inspector

subtle lodge
#

to what should I assign it ?

#

oh

#

in the tutorial he does this, but this won't work for me as the text keeps changing during the day depending on the routine

subtle lodge
#

Like this ?

pearl ocean
#

yeah, that can be simplified but it should work just fine

subtle lodge
#

but when switching to another language it gives me the right text until the next routine where it gives me that gibberish text

pearl ocean
#

looks like line 76 in your first screenshot

#

you're converting the LocalizedString object description instead of the actual value

subtle lodge
pearl ocean
#

you want GetLocalizedString() instead of ToString()

#

line 83

subtle lodge
subtle lodge
pearl ocean
#

try instantiating it in the same line as you're declaring the object

subtle lodge
#

isn't that what I'm already doing at line 39 ? ๐Ÿค”

pearl ocean
#

I can see in the docs that changing the TableEntryReference should also trigger the StringChanged event
if that's the case then you can skip assigning the text on OnDailyRoutineChange

pearl ocean
subtle lodge
pearl ocean
#

by doing that you'll also be able to get rid of all those "DailyRoutines" table references, you only need it once during initialization

pearl ocean
subtle lodge
pearl ocean
#

you're already doing it on OnStringChanged

pearl ocean
#

you can delete line 35 and 39, that has been defined previously already

subtle lodge
#

done ๐Ÿ‘

pearl ocean
#

also consider calling OnDailyRoutineChange instead of duplicating the code on Start

subtle lodge
pearl ocean
#

correct, it should be very similar to the method, if not the same

#

actually you might want to subscribe to the event before assigning the TableEntryReference

subtle lodge
#

but it's kinda weird as I never use all that boilerplate code because at the end I'm using the localizedText argument ๐Ÿค”

pearl ocean
#

no, wait ๐Ÿ˜‚ something went wrong there

#

do you mind posting the whole code somewhere? !code

whole wedgeBOT
subtle lodge
#

yeah ๐Ÿ˜„

subtle lodge
pearl ocean
subtle lodge
#

This is the code for it in my DailyRoutineManager.cs class

pearl ocean
#

maybe this is running before HUDManager.Start?
I can't say much about the rest of the logic though

subtle lodge
pearl ocean
subtle lodge
subtle lodge
#

@pearl ocean Everything works perfectly now, thank you so much ๐Ÿ‘

#

I'm trying to make a step by step document on how to properly do things for next time and here's what I have :

subtle lodge
#

To summarize the localization things :

    1. Install the Localization package
    1. Choose the languages I want to localize
    1. Create the Localization table
    1. Create entries and give them name for the key
    1. Fill those entries with appropriate translation for each language

In Code :

    1. Create a string variable that contains the name of the table ( i.e tableName)
    1. Create a string variable that contains the name of the entry (i.e tableEntry)
    1. Create a LocalizedString variable and instantiate it to a new LocalizedString(tableName, tableEntry);
    1. Subscribe to StringChanged for the localized string variable in OnEnable()
    1. In OnStringChanged method, change the UI text there by assigning the parameter localizedText to it