44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
using AibisDream.Utility;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.Localization.Components;
|
|
|
|
namespace AibisDream
|
|
{
|
|
[RequireComponent(typeof(TMP_Text))]
|
|
[RequireComponent(typeof(LocalizeStringEvent))]
|
|
public class LocalizedText : MonoBehaviour
|
|
{
|
|
private TMP_Text _text;
|
|
private LocalizeStringEvent _localizeEvent;
|
|
|
|
public bool isLineText = true;
|
|
public string template = "{0}";
|
|
|
|
private void OnUpdateString(string text)
|
|
{
|
|
if (isLineText)
|
|
{
|
|
text = CommonUtil.RemoveName(text);
|
|
}
|
|
|
|
_text.text = string.Format(template, text);
|
|
}
|
|
|
|
public void SetLocalizedText(string table, string entry)
|
|
{
|
|
_text = GetComponent<TMP_Text>();
|
|
_localizeEvent = GetComponent<LocalizeStringEvent>();
|
|
|
|
_localizeEvent.OnUpdateString.AddListener(OnUpdateString);
|
|
|
|
_localizeEvent.SetTable(table);
|
|
_localizeEvent.SetEntry(entry);
|
|
}
|
|
|
|
public void SetVariables()
|
|
{
|
|
|
|
}
|
|
}
|
|
} |