using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; using UnityEngine.UI; namespace Assets.Scripts.UI.Control { [RequireComponent(typeof(Text))] public class PFUIText : PFUIComponentBase { public string key; protected Text text; public string Text { get { return text.text; } set { text.text = value; } } protected void Awake() { text = this.transform.GetComponent(); if (string.IsNullOrEmpty(key)) { key = text.text;//默认英文内容为key值 } } protected void Start() { //Debug.Log(text.text); if (App.LanguageManager != null && App.LanguageManager.ContainsKey(key)) { //Debug.Log(text.text); text.text = App.LanguageManager[key]; } App.ChangeLanguageEvent += App_ChangeLanguageEvent; } private void App_ChangeLanguageEvent() { if (App.LanguageManager != null && App.LanguageManager.ContainsKey(text.text)) { text.text = App.LanguageManager[key]; } } } }