Author Topic: NGUI HUD Text + Localization  (Read 2597 times)

fanling3

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 29
    • View Profile
NGUI HUD Text + Localization
« on: March 24, 2014, 03:36:28 AM »
I tried to add localization support to HUD Text, here is what I done to HUDText.cs:

  1. protected class Entry {
  2.     public UILocalize localize;
  3. }
  4.  
  5. Entry Create() {
  6.     ne.localize = ne.label.transform.gameObject.AddComponent<UILocalize>();
  7. }

It works, but sometimes. For example, I added a new Key to localization.csv named "HP", and have content "HitPoint" for, let's say, French

when I add 10 HUD by using .Add function in HUDText, I will see several "Hitpoint", and several "HP". It doesn't work 100%. When I pause the game and check for the UILabel Object, I can still see the UILocalize component inside but with the text "HP", while some of them had text "HitPoint", other part looks the same.

Any idea?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI HUD Text + Localization
« Reply #1 on: March 24, 2014, 06:41:55 PM »
You don't need UILocalize for this.

When assigning text to HUDText, just pass the already localized value like so:

hudText.Add(Localization.Get("Some Text"), ...);