备份CatanBuilding瘦身独立工程
This commit is contained in:
49
Assets/Scripts/AOTScripts/Localize.cs
Normal file
49
Assets/Scripts/AOTScripts/Localize.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using asap.core;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace GameC
|
||||
{
|
||||
public enum TextType
|
||||
{
|
||||
Text, // UGUI Text
|
||||
TextMeshPro, // TextMeshPro - Text
|
||||
TextMeshPro_UGUI // TextMeshPro - Text(UI)
|
||||
}
|
||||
|
||||
public class Localize : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private string key;
|
||||
[SerializeField] private TextType textType = TextType.TextMeshPro_UGUI;
|
||||
|
||||
|
||||
private TMP_Text text_UGUI;
|
||||
|
||||
private IDisposable disposable;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
return;
|
||||
}
|
||||
text_UGUI = gameObject.GetComponent<TextMeshProUGUI>();
|
||||
OnChangeLanguage();
|
||||
}
|
||||
|
||||
|
||||
void OnChangeLanguage()
|
||||
{
|
||||
string localized_text = Boostrapi18n.Instance.GetText(key);
|
||||
|
||||
if (!string.IsNullOrEmpty(localized_text))
|
||||
if (text_UGUI)
|
||||
{
|
||||
text_UGUI.text = localized_text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user