Files
unity/Assets/Game/Scripts/Localization/LocalizedWorldLabel.cs
RCiBot 92623a1bc8 feat: establish mech extraction prototype with bilingual UI
Track Unity source, scenes, editable assets, licenses, tools and QA evidence. Exclude generated caches, Windows builds and raw runtime logs.
2026-11-12 12:28:40 +08:00

31 lines
903 B
C#

using UnityEngine;
namespace Ironspore
{
[RequireComponent(typeof(TextMesh))]
public sealed class LocalizedWorldLabel : MonoBehaviour
{
string key;
TextMesh label;
public void Initialize(string textKey)
{
key = textKey;
label = GetComponent<TextMesh>();
if (GameLocalization.Catalog && GameLocalization.Catalog.worldFont)
{
label.font = GameLocalization.Catalog.worldFont;
GetComponent<MeshRenderer>().sharedMaterial = label.font.material;
}
Refresh();
}
void OnEnable() => GameLocalization.Changed += Refresh;
void OnDisable() => GameLocalization.Changed -= Refresh;
void Refresh()
{
if (label && !string.IsNullOrEmpty(key))
label.text = GameLocalization.Text(key);
}
}
}