using System; using Unheimlich.UI; using UnityEngine; using OctoFramework = OctoCore.OctoCore; using OctoCore.Localization; namespace Unheimlich.Features.Dialogue { [RequireComponent(typeof(PerLetterFontShifter))] public class LocalizedSubtitle : MonoBehaviour { [SerializeField] private OctoLocalizedTextData _data; private OctoLocalizedText _localizedText; // A retirer private PerLetterFontShifter _shifter; private Action localize; void Awake() { _localizedText = GetComponent(); // A retirer _shifter = GetComponent(); if (!OctoFramework.Instance) { Debug.LogWarning($"OctoCore.Instance not found"); return; } Localize(); OctoFramework.Instance.Localization.SubscribeOnLanguageWrittenChange(localize = Localize); } void OnDestroy() { if (!OctoFramework.Instance) return; if (localize != null) { OctoFramework.Instance.Localization.UnsubscribeOnLanguageWrittenChange(localize); localize = null; } } private void Localize() { string localized = "Not localized"; if (_data) { localized = OctoLocalization.GetLocalizedText(_data); } else // A retirer { // A retirer _localizedText.Localize(); // A retirer localized = GetComponent().text; // A retirer } // A retirer // Read it back from the source TMP (it's disabled but the .text field is still set). _shifter.SetText(localized); } } }