playMaker

Author Topic: GUI Button - using variable to set names, buttons getting same name.  (Read 2124 times)

Jos Yule

  • Playmaker Newbie
  • *
  • Posts: 33
Hello all.

I'm working on creating a localization/translation action/script(s).

I have something working - ie. i have a script which reads an XML file and i can then call GetText(id) on it to get different translations.

What i was then doing is setting a string variable (translated_text) via a new Set Translation action i created.

Again, this is all working peachy.

I was then using this variable to set the text on a GUI Button.

All good.

However, the issue starts if i have more then 1 GUI Button actions in 1 State, and i am setting the `translated_text` variable in-between those actions. In this case, because of the way OnGUI and the setting of the content to a new instance of GUIContent() in OnGUI (in the GUIContentAction class, parent to GUIButton), both buttons get the same name - the last value `translated_text` was set too.

If the text.Value was cached in a local var (or something), in a OnEnter or some other 1 time fired method, and then used in the OnGUI method, this would not happen.

I'm not sure if anyone takes advantage of the fact that you can change the name on a button dynamically the way it currently is. I just know that having to setup a different variable for each button name takes some of the niceness out of it.

I could also, i suppose, override the GUI Button action and make a GUI Translated Button, which would get the translated value itself.

Anyway, any suggestions or comments about this would be great!

Thanks
Jos