2021-03-29 09:10:59 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using UnityEngine;
|
2021-04-19 14:36:08 +08:00
|
|
|
|
using UnityEngine.UI;
|
2021-03-29 09:10:59 +08:00
|
|
|
|
|
|
|
|
|
|
namespace Assets.Scripts.UI.Control
|
|
|
|
|
|
{
|
2021-04-19 14:36:08 +08:00
|
|
|
|
[RequireComponent(typeof(Text))]
|
|
|
|
|
|
public class PFUIText : PFUIComponentBase
|
2021-03-29 09:10:59 +08:00
|
|
|
|
{
|
2021-11-10 18:13:38 +08:00
|
|
|
|
public string key;
|
2022-02-23 18:14:31 +08:00
|
|
|
|
protected Text text;
|
2021-04-21 11:25:52 +08:00
|
|
|
|
|
|
|
|
|
|
public string Text
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return text.text;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
text.text = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-04-19 14:36:08 +08:00
|
|
|
|
protected void Awake()
|
|
|
|
|
|
{
|
2021-04-21 11:25:52 +08:00
|
|
|
|
text = this.transform.GetComponent<Text>();
|
2021-11-10 18:13:38 +08:00
|
|
|
|
if (string.IsNullOrEmpty(key))
|
|
|
|
|
|
{
|
|
|
|
|
|
key = text.text;//默认英文内容为key值
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
protected void Start()
|
|
|
|
|
|
{
|
2021-11-23 14:25:36 +08:00
|
|
|
|
//Debug.Log(text.text);
|
2021-11-10 18:13:38 +08:00
|
|
|
|
if (App.LanguageManager != null && App.LanguageManager.ContainsKey(key))
|
|
|
|
|
|
{
|
2021-11-23 14:25:36 +08:00
|
|
|
|
//Debug.Log(text.text);
|
2021-11-10 18:13:38 +08:00
|
|
|
|
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];
|
|
|
|
|
|
}
|
2021-04-19 14:36:08 +08:00
|
|
|
|
}
|
2021-03-29 09:10:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|