FontChooserComponent.cs 999 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. /// <summary>
  6. /// 字体选择器,当字体为繁体时自动选择另一套字体
  7. /// </summary>
  8. public class FontChooserComponent : MonoBehaviour {
  9. public Font m_Traditional;
  10. public Font m_Simplified;
  11. Text m_text;
  12. void Start ()
  13. {
  14. if (m_text == null)
  15. {
  16. m_text = GetComponent<Text>();
  17. }
  18. ResetLanguage();
  19. GlobalEvent.AddEvent(LanguageEventEnum.LanguageChange, ReceviceLanguageChange);
  20. }
  21. void ResetLanguage()
  22. {
  23. if (m_text != null)
  24. {
  25. if (LanguageManager.s_currentLanguage == SystemLanguage.ChineseTraditional)
  26. {
  27. m_text.font = m_Traditional;
  28. }
  29. else
  30. {
  31. m_text.font = m_Simplified;
  32. }
  33. }
  34. }
  35. void ReceviceLanguageChange(params object[] objs)
  36. {
  37. ResetLanguage();
  38. }
  39. }