本地化问题修改

This commit is contained in:
2025-05-09 18:54:30 +08:00
parent 107a6cbc4b
commit e7b30e25e5
17 changed files with 635 additions and 210 deletions
@@ -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