using TMPro; using UnityEngine.ResourceManagement.AsyncOperations; namespace RoR2.UI; public class HGTextMeshProUGUI : TextMeshProUGUI { public bool useLanguageDefaultFont = true; public static TMP_FontAsset defaultLanguageFont; [InitDuringStartup] private static void Init() { Language.onCurrentLanguageChanged += OnCurrentLanguageChanged; OnCurrentLanguageChanged(); } private static void OnCurrentLanguageChanged() { AsyncOperationHandle asyncOperationHandle = LegacyResourcesAPI.LoadAsync(Language.GetString("DEFAULT_FONT")); asyncOperationHandle.Completed += delegate(AsyncOperationHandle x) { defaultLanguageFont = x.Result; }; } protected override void Awake() { base.Awake(); if (useLanguageDefaultFont && defaultLanguageFont != null) { base.font = defaultLanguageFont; UpdateFontAsset(); } } }