UI换了很多,spine主视觉停用

This commit is contained in:
FloatGaming
2026-06-15 20:17:25 +08:00
parent 5eec879582
commit 216ab08e8d
3634 changed files with 814422 additions and 382766 deletions
@@ -0,0 +1,64 @@
using UnityEngine;
using UnityEngine.UI;
[DisallowMultipleComponent]
[RequireComponent(typeof(Text))]
public class LocalizedText : MonoBehaviour
{
[SerializeField] private string localizationKey;
[TextArea]
[SerializeField] private string fallbackText;
private Text _text;
private void Awake()
{
_text = GetComponent<Text>();
}
private void OnEnable()
{
LocalizationService.EnsureInitialized();
LocalizationService.LanguageChanged += HandleLanguageChanged;
Refresh();
}
private void OnDisable()
{
LocalizationService.LanguageChanged -= HandleLanguageChanged;
}
public void Refresh()
{
if (_text == null)
{
_text = GetComponent<Text>();
}
if (_text == null)
{
return;
}
string fallback = string.IsNullOrEmpty(fallbackText) ? _text.text : fallbackText;
if (string.IsNullOrWhiteSpace(localizationKey))
{
_text.text = LocalizationService.LocalizeLiteral(fallback);
return;
}
if (LocalizationService.TryGet(localizationKey, out string localized))
{
_text.text = localized;
return;
}
_text.text = LocalizationService.LocalizeLiteral(fallback);
}
private void HandleLanguageChanged(string languageCode)
{
Refresh();
}
}