Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 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 /
  • Help Room /
avatar image
0
Question by Aziz1989 · Oct 22, 2015 at 10:02 PM · c#uilocalizationunity 5.2internationalization

Smart localization asset with the Unity Samples: UI

Hello,

I hope to find a quick answer i am really new to the Ui, GUI and specially localization techniques, well i should have the Unity Samples: UI 3D menu (that you can find in the scene folder of the project) to make it change languages for the system language or the chosen language using Smart localization assets... i so far been able to do it with text i create myself but to access the "Unity Samples: UI" element and change them when ever i wanted i just failed and all this is for hours later so... please try to help me even if this could be obvious solution... thank you and this is my code that i've attached to the canvas of the 3D scene (from the Unity Samples project) :

 using UnityEngine;
 using System.Collections;
 using SmartLocalization;
 using System.Collections.Generic;
 
 public class SmartLocTutorial : MonoBehaviour
 {
 
     string _welcome;
     string _newGame;
     AudioClip _playSound;
     GameObject _gameObject;
     Texture _texture;
     private Dictionary<string,string> currentLanguageValues;
     private List<SmartCultureInfo> availableLanguages;
     // Use this for initialization
     void Start ()
     {
         LanguageManager languageManager = LanguageManager.Instance;
         SmartCultureInfo systemLanguage = languageManager.GetSupportedSystemLanguage ();
         if (systemLanguage != null) {
             languageManager.ChangeLanguage (systemLanguage);    
         }
         
         if (languageManager.NumberOfSupportedLanguages > 0) {
             currentLanguageValues = languageManager.RawTextDatabase;
             availableLanguages = languageManager.GetSupportedLanguages ();
         } else {
             Debug.LogError ("No languages are created!, Open the Smart Localization plugin at Window->Smart Localization and create your language!");
         }
         languageManager.OnChangeLanguage += OnChangeLanguage;
 //        languageManager.ChangeLanguage ("en");
     }
     void OnDestroy ()
     {
         if (LanguageManager.HasInstance)
             LanguageManager.Instance.OnChangeLanguage -= OnChangeLanguage;
     }
 
     void OnChangeLanguage (LanguageManager thisLanguageManager)
     {
 //        _welcome = thisLanguageManager.GetTextValue ("Welcome.Key");
         GameObject.Find ("TitleLabel").GetComponentInChildren<GUIText> ().text = thisLanguageManager.GetTextValue ("Welcome.Key");
 //        _newGame = thisLanguageManager.GetTextValue ("NewGame.Key");
         GameObject.Find ("_newGame").GetComponentInChildren<GUIText> ().text = thisLanguageManager.GetTextValue ("NewGame.Key");
         _playSound = thisLanguageManager.GetAudioClip ("PlaySound.Key");
         _texture = thisLanguageManager.GetTexture ("Texture.key");
         _gameObject = thisLanguageManager.GetPrefab ("GameObj.key");
     }
 
     void OnGui ()
     {
 //        if (GUILayout.Button ("English")) {
 //            LanguageManager.Instance.ChangeLanguage ("en");
 //        }    
 //        if (GUILayout.Button ("Français")) {
 //            LanguageManager.Instance.ChangeLanguage ("fr");
 //        }
     }
     // Update is called once per frame
 //    void Update ()
 //    {
 //    
 //    }
 }


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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by NiklasBorglund · Oct 26, 2015 at 08:14 PM

I just made an example of how the whole Unity3D Sample UI asset could work with Smart Localization and put it up on GitHub : https://github.com/NiklasBorglund/SampleUIExample-SmartLocalization

Hope it helps!

Comment
Add comment · Show 1 · 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 Aziz1989 · Nov 09, 2015 at 03:46 PM 0
Share

Oh thank you Niklas i was really in a hurry so i did just the same you did with the project in the GitHub, i was doing it wrong but it worked, so thank you for the effort, it was a question out of stress sorry. hope it will be helpful for other beginners .

avatar image
0

Answer by Aziz1989 · Oct 26, 2015 at 08:29 AM

Hey why you are not answering me?

Comment
Add comment · 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

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

39 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

CharacterInfo.glyphWidth always 0 2 Answers

Scaling an image sent to UI Image 0 Answers

Refresh Chat room messages 1 Answer

How do I make an external text document show only between certain lines in UI Text 1 Answer

Method Skipping Inputs 2 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