50 lines
1.1 KiB
C#
50 lines
1.1 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|
|
}
|