Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Assalino · Jun 17, 2015 at 12:58 AM · textuser interfacelocalization

Finding all text labels in a scene

Hi,

In an effort to localise a game which is being published for iOS and Android, I'd like to get all of the strings from the CMS.

The best possible way I can see this working, is naming my labels with something like "COPY_TITLE", "COPY_DESCRIPTION", "COPY_INTRO", and so on. These labels could then have whatever values at build time, but then at runtime, when we get new values from the CMS, I'd my initial setup to just iterate through every single label in the scene, active or non-active, and see if its name contains "COPY_". If so, find the matching value to that key, in the data received from the CMS.

Is there a way of doing this, or perhaps a different/better way of going about it?

I'm using Unity 5 PRO, if it helps.

Thanks

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by DoTA_KAMIKADzE · Jun 17, 2015 at 01:05 AM

By labels you mean the GUI.Label or UI Text or ...? If UI Text, then what you want is this:

     Text[] yourLabels = FindObjectsOfType<Text>();
     foreach (Text someLabel in yourLabels)
     {
         //do here whatever you need
     }

If you're using GUI.Label then you could simply use your source of strings directly? E.g. if it would be a list/array:

     GUI.Label(new Rect(10, 10, 100, 20), yourSourceOfStrings[4]);//or whichever one this label should be using

As for the different/better way I'd suggest you firstly to go through FREE Localizations out THERE and check their code, maybe you wouldn't even want to do your own localization after that in first place.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Assalino · Jun 19, 2015 at 06:48 PM 0
Share

That's perfect. It was for UI text, so the 1st one worked great. Thanks

avatar image AleMarcati · Mar 26 at 02:37 PM 0
Share

Is there a way to search the scene for all objects that are assets with a certain label? I'm trying to search l:Dynamic for objects that have the Dynamic tag but it only finds in the project, not in the scene.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Modifying line order in UI Text component 0 Answers

I made a text object in a script but Unity doesnt let me place the UI text in the box. 1 Answer

Scale UI Text 0 Answers

UI Text Small on screen device. 1 Answer

Localization in the new uGUI 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges