Localization in the new uGUI

Prior to 4.6, the team I work with used EZGUI to do their UI.

We were able to accomplish localization by placing the stringids in EZGUIs text objects and then modify the Awake function of that object to replace it’s text with the proper text from our localization manager. This was very fast due to the fact that it was handled in each of the text objects awake functions rather than searching for each text object in the scene to replace its text.

Looking at the new unity UI I’m not seeing a really great way of replacing the text on each of the text objects. Certainly, I could search through all of the objects in the scene and replace the text on each one, but that would be tremendously slow in a large-scale project. I could also place a component on each text object to replace the text but again, that wouldn’t be ideal as the component would have to get the text component and that would be a bit slow with all of the text objects in a large-scale project.

I also thought about creating new classes that derive from the Text class and override the awake to do our localization. The only downside to this is that I wouldn’t be able to remove the old Text component from the context menu when adding an object, and I would also have to derive from other classes such as the button class to ensure that it doesn’t automatically add the old Text object underneath itself. This could prove to be a hassle as we would have to ensure that everyone on the project didn’t accidentally choose the old class when setting up UI for the game.

I’m looking for some suggestions of things that I could do to accomplish this. Perhaps I missed something when looking through the new UI classes. I’m really hoping there’s a better way to go about doing this and that I don’t have to go with one of the solutions listed above.

Thanks in advance for all of your help!

Well, I just found this: (scroll to the bottom)

http://www.pixelcrushers.com/dialogue_system/manual/html/unity_u_i_dialogue_u_i.html

I was also looking for that solution! :smiley:

Well, hmmm. Unity’s UI is open source, so you could modify the code of the standard Text object to suit your needs, right?

I can only think of one way for this:
Override the MenuItem for Button or Text or anyother components includes a text.

[MenuItem(“GameObject/UI/Button”, false, 2030)]
for more detail , you can check out the Unity ui source code .