UITextStyleComponent.cs 709 B

12345678910111213141516171819202122232425262728293031
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. [RequireComponent(typeof(Text))]
  6. public class UITextStyleComponent : MonoBehaviour {
  7. public string styleName;
  8. private Text text;
  9. // Use this for initialization
  10. void Start () {
  11. SystemLanguage language = LanguageManager.s_currentLanguage;
  12. SetTextStyleData(language);
  13. }
  14. // Update is called once per frame
  15. public void SetTextStyleData (SystemLanguage language)
  16. {
  17. if(text==null)
  18. text = GetComponent<Text>();
  19. if (string.IsNullOrEmpty(styleName))
  20. return;
  21. UITextStyleManager.SetText(text, styleName, language);
  22. }
  23. }