using UnityEngine; using Kill.Managers; using UnityEngine.UI; using System; namespace Kill.UI.Components { public class MultiLanguageText : MonoBehaviour { [Tooltip("对应LanguageConfig.json中的键")] public string textKey; // 在Inspector中设置,如"btn_start" private Text textComponent; Action callback; string callbackStr; private void Awake() { textComponent = GetComponent(); UpdateText(); } // 更新文本(语言切换时调用) public void UpdateText() { if (!string.IsNullOrEmpty(textKey)) { if (textComponent != null) { textComponent.text = LanguageManager.Instance.GetLanguage(textKey); } } callback?.Invoke(callbackStr); } public void SetCallBack(Action action,string str) { callback=action; callbackStr=str; } } }