TextLocalization.cs 521 B

123456789101112131415161718
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. [RequireComponent(typeof(Text))]
  4. public class TextLocalization : MonoBehaviour
  5. {
  6. public string key;
  7. void Start() {
  8. // Get the string value from localization manager from key
  9. // and set the text component text value to the returned string value
  10. GetComponent<Text>().text = LocalizationManager.Instance.GetText(key);
  11. }
  12. public void UpdateText() {
  13. GetComponent<Text>().text = LocalizationManager.Instance.GetText(key);
  14. }
  15. }