TextLocalization.cs 705 B

1234567891011121314151617181920212223
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System;
  4. [RequireComponent(typeof(Text))]
  5. public class TextLocalization : MonoBehaviour
  6. {
  7. public string key;
  8. void Start() {
  9. // Get the string value from localization manager from key
  10. // and set the text component text value to the returned string value
  11. string text = LocalizationManager.Instance.GetText(key);
  12. text = text.Replace("\\n", Environment.NewLine);
  13. GetComponent<Text>().text = text;
  14. }
  15. public void UpdateText() {
  16. string text = LocalizationManager.Instance.GetText(key);
  17. text = text.Replace("\\n", Environment.NewLine);
  18. GetComponent<Text>().text = text;
  19. }
  20. }