Author Topic: make a UILabel autotranslate itself  (Read 9403 times)

Lotti

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 47
    • View Profile
make a UILabel autotranslate itself
« on: June 10, 2013, 01:18:49 PM »
hello! i'm new here, newbie with unity and newbie with ngui :P

i need to make UILabel autotranslate itself calling a custom method (of mine) that will return translated value inside mText attribute. So, the default value inserted in object inspector will be the key to use inside the "translation array".

i tried putting the translation inside text setter and it works well, but only for run-time setted labels. when i play the scene the value inside the object inspector is replaced with the translated one, when i stop the scene the original value comes back.

so i tried to put the translation inside onStart and on Update too but a very strange problem occurs: the new translated value appears inside object inspector when in play mode, but stays there also when i stop playing the game!

how can i fix this strange behaviour?

thank you.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: make a UILabel autotranslate itself
« Reply #1 on: June 10, 2013, 02:41:30 PM »
Have you look at the Localization example? Because that's exactly how UILocalize script works.

As for going from Play to Edit... values are supposed to "come back". Nothing carries over from Play to Edit. That's how Unity works.

Lotti

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 47
    • View Profile
Re: make a UILabel autotranslate itself
« Reply #2 on: June 10, 2013, 04:08:11 PM »
thank you. tomorrow i will try it and let you know.

Lotti

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 47
    • View Profile
Re: make a UILabel autotranslate itself
« Reply #3 on: June 12, 2013, 02:31:30 AM »
well obviously, your script worked flawless :P so i added UILocalize to each UILabel applying to prefabs too. everything worked for the 5 "play" times. so i moved to script other things, and translation disappeared :P

i will investigate it further in development. thank you.