本地化问题修改
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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;
|
||||
|
||||
private void OnUpdateString(string text)
|
||||
{
|
||||
var textArr = text.Split(":");
|
||||
_text.text = textArr.Length > 1 ? textArr[1].Trim() : 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c9c71a7e9c9455d955ff20b5db823a1
|
||||
timeCreated: 1746702086
|
||||
Reference in New Issue
Block a user