using UnityEngine.UI;
|
using System.Text;
|
using UnityEngine;
|
|
public class TextEx : Text
|
{
|
[SerializeField]
|
bool m_IsKey = false;
|
public bool isKey {
|
get {
|
return m_IsKey;
|
}
|
set {
|
m_IsKey = value;
|
}
|
}
|
|
[SerializeField]
|
TextColType m_ColorType = TextColType.None;
|
public TextColType colorType {
|
get { return m_ColorType; }
|
set {
|
if (m_ColorType != value)
|
{
|
m_ColorType = value;
|
this.color = UIHelper.GetUIColor(value);
|
}
|
}
|
}
|
|
protected override void Awake()
|
{
|
if (Application.isPlaying)
|
{
|
//设置默认的字体
|
if (isKey)
|
{
|
this.text =UIHelper.ReplaceNewLine(Language.Get(this.text));
|
}
|
|
Language.languageChangeEvent += OnLanguageSwitch;
|
}
|
|
if (colorType != TextColType.None)
|
{
|
this.color = UIHelper.GetUIColor(colorType);
|
}
|
}
|
|
protected override void OnDestroy()
|
{
|
Language.languageChangeEvent -= OnLanguageSwitch;
|
}
|
|
private void OnLanguageSwitch()
|
{
|
//重新加载字体
|
}
|
|
}
|