using UnityEngine; using TMPro; using ArabicSupport; [RequireComponent(typeof(TextMeshProUGUI))] public class LocalizedTextComponent : MonoBehaviour { public string localizationKey; private TextMeshProUGUI tmp; private void Start() { tmp = GetComponent(); if (LanguageManager.Instance != null) { LanguageManager.Instance.Register(this); UpdateText(); } else { Debug.LogWarning($"LanguageManager is not initialized yet for {gameObject.name}. Skipping registration."); } } void OnDestroy() { if (LanguageManager.Instance != null) { LanguageManager.Instance.Unregister(this); } } public void UpdateText() { if (LanguageManager.Instance == null) { Debug.LogWarning($"LanguageManager not available when updating text for {gameObject.name}"); return; } bool isArabic = LanguageManager.Instance.currentLanguage == "Arabic"; string rawText = LanguageManager.Instance.GetLocalizedText(localizationKey); tmp.text = isArabic ? ArabicFixer.Fix(rawText) : rawText; tmp.font = LanguageManager.Instance.GetCurrentFont(); //tmp.isRightToLeftText = isArabic; //tmp.alignment = isArabic ? TextAlignmentOptions.Right : TextAlignmentOptions.Left; } }