40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
#if TEXTMESHPRO_SUPPORT
|
|
|
|
using TMPro;
|
|
|
|
namespace UnityEngine.UI
|
|
{
|
|
public class UXTextMeshPro : TextMeshProUGUI
|
|
{
|
|
[SerializeField] private int m_localizationID;
|
|
[SerializeField] private string m_localizationKey = "";
|
|
|
|
protected override void Start()
|
|
{
|
|
base.Start();
|
|
if (!Application.isPlaying) return;
|
|
ChangeLanguage();
|
|
}
|
|
|
|
protected void ChangeLanguage()
|
|
{
|
|
if (!string.IsNullOrEmpty(m_localizationKey) && !"None".Equals(m_localizationKey) && UXComponentExtensionsHelper.LocalizationHelper != null)
|
|
{
|
|
text = UXComponentExtensionsHelper.LocalizationHelper.GetString(m_localizationKey);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 重新动态设置多语言
|
|
/// </summary>
|
|
/// <param name="localizationID"></param>
|
|
public void SetLocalization(string localizationID)
|
|
{
|
|
m_localizationKey = localizationID;
|
|
ChangeLanguage();
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|