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(); if (GameLocalization.Catalog && GameLocalization.Catalog.worldFont) { label.font = GameLocalization.Catalog.worldFont; GetComponent().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); } } }