using TMPro; using UnityEngine; [DisallowMultipleComponent] [RequireComponent(typeof(TMP_Text))] public class LocalizedTMP : MonoBehaviour { [SerializeField] string key; TMP_Text label; public string Key { get => key; set { key = value; Apply(); } } void Awake() { label = GetComponent(); } void OnEnable() { SaveService.EnsureLoaded(); LocaleService.Changed += Apply; Apply(); } void OnDisable() { LocaleService.Changed -= Apply; } public void Apply() { if (label == null) label = GetComponent(); if (label == null || string.IsNullOrEmpty(key)) return; label.text = L.Get(key); } }