ButtonLocalization.cs 607 B

12345678910111213141516171819
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. [RequireComponent(typeof(Button))]
  5. public class ButtonLocalization : 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. GetComponent<Button>().GetComponentInChildren<Text>().text = LocalizationManager.Instance.GetText(key);
  12. }
  13. internal void UpdateText() {
  14. GetComponent<Button>().GetComponentInChildren<Text>().text = LocalizationManager.Instance.GetText(key);
  15. }
  16. }