NGUI Label with dynamic term
10 years 1 month ago - 10 years 1 month ago #498
by StKiller
NGUI Label with dynamic term was created by StKiller
Hello,
I have a button which has action depending on context. So, from code, I update button's caption to either "one", "two" or "three".
I have these terms defined in the localization source and there is attached an localization component to the button's label.
The problem is that the localization is not always updated when the label 'text' field is updated. Can I force it to refresh the localization, somehow?
Thank you in advance.
**Update**
I started to use api for in-code localization and removed the localization component from the label itself. Now it works fine.
I have a button which has action depending on context. So, from code, I update button's caption to either "one", "two" or "three".
I have these terms defined in the localization source and there is attached an localization component to the button's label.
The problem is that the localization is not always updated when the label 'text' field is updated. Can I force it to refresh the localization, somehow?
Thank you in advance.
**Update**
I started to use api for in-code localization and removed the localization component from the label itself. Now it works fine.
Last edit: 10 years 1 month ago by StKiller.
Please Log in or Create an account to join the conversation.
10 years 1 month ago #499
by Frank
Are you
Give I2L
5 stars!
Are you
Please lets us know how to improve it!
Replied by Frank on topic NGUI Label with dynamic term
Hi,
The Localize component takes the Label's text only when its enabled for the first time, if it doesn't have a term.
To change the localized term at runtime, you need to call the function SetTerm of the localize component:
Calling the SetTerm will change the term that is used and will update the label's text with the translation.
Thanks,
Frank
The Localize component takes the Label's text only when its enabled for the first time, if it doesn't have a term.
To change the localized term at runtime, you need to call the function SetTerm of the localize component:
// Instead of
// label.text = "one";
// call:
label.GetComponent<Localize>().SetTerm("one", null);
Calling the SetTerm will change the term that is used and will update the label's text with the translation.
Thanks,
Frank
Are you

Are you

To get the betas as soon as they are ready,
check this out
Please Log in or Create an account to join the conversation.
Time to create page: 0.172 seconds