#Here's the error, the text on my UI
1 messages ยท Page 1 of 1 (latest)
Isn't this the assignation ?
no, you're already accessing properties inside that object without ever assiging anything to it
oh
you either need to create a new instance of it during runtime or assign it through the inspector
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
you can see a few examples here: https://docs.unity3d.com/Packages/com.unity.localization@1.5/api/UnityEngine.Localization.LocalizedString.html
Like this ?
yeah, that can be simplified but it should work just fine
it works first for few hours, but then it gave me this
but when switching to another language it gives me the right text until the next routine where it gives me that gibberish text
looks like line 76 in your first screenshot
you're converting the LocalizedString object description instead of the actual value
You're the best, thank you so much ๐
can I skip line 40 and 41 as I already use it in line 39 at the instantiation ?
try instantiating it in the same line as you're declaring the object
isn't that what I'm already doing at line 39 ? ๐ค
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
yes, but ideally you should move that as close as possible to the object initialization, right now it would give you a null reference exception if you try to access that variable during Awake
so what's the best place to do that in ? Awake() ? On Enable() ?
by doing that you'll also be able to get rid of all those "DailyRoutines" table references, you only need it once during initialization
private LocalizedString dailyRoutineLocalizedString = new LocalizedString("DailyRoutines", string.Empty);
So I should delete all of this ?
just line 83, the rest is necessary
you're already doing it on OnStringChanged
like so ?
you can delete line 35 and 39, that has been defined previously already
done ๐
also consider calling OnDailyRoutineChange instead of duplicating the code on Start
for what code exactly ? from line 34 to 38 ?
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
but it's kinda weird as I never use all that boilerplate code because at the end I'm using the localizedText argument ๐ค
no, wait ๐ something went wrong there
do you mind posting the whole code somewhere? !code
๐ Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
yeah ๐
A tool for sharing your source code with the world!
check this: https://paste.mod.gg/urcwwxdorrdq/
(line 46 should also be removed)
A tool for sharing your source code with the world!
Nice, it still work ๐ Except the first time when launching but I think it's has to do with my code logic about the daily routine where the routine between 23:00 and 6:00 isn't properly chosen because of a logic issue ๐ฌ
This is the code for it in my DailyRoutineManager.cs class
maybe this is running before HUDManager.Start?
I can't say much about the rest of the logic though
No because the next day it's the same issue as the routine "Lights Out" never shows up in my UI ever, and keeps staying at "Night Roll Call" between 10 PM and 6 AM. So the first day nothing appears in the UI for the text of the routine until 6 AM
aren't you always displaying the last task that matches the time?
it seems to be overriding all the previous ones
Here's my code if you want to check it ๐ https://paste.mod.gg/hueiygauxboh/4
A tool for sharing your source code with the world!
@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 :
To summarize the localization things :
-
- Install the Localization package
-
- Choose the languages I want to localize
-
- Create the Localization table
-
- Create entries and give them name for the key
-
- Fill those entries with appropriate translation for each language
In Code :
-
- Create a string variable that contains the name of the table ( i.e
tableName)
- Create a string variable that contains the name of the table ( i.e
-
- Create a string variable that contains the name of the entry (i.e
tableEntry)
- Create a string variable that contains the name of the entry (i.e
-
- Create a
LocalizedStringvariable and instantiate it to anew LocalizedString(tableName, tableEntry);
- Create a
-
- Subscribe to
StringChangedfor the localized string variable inOnEnable()
- Subscribe to
-
- In
OnStringChangedmethod, change the UI text there by assigning the parameterlocalizedTextto it
- In