Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of KoreanFontFallback v1.0.0
KoreanFontFallback.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Logging; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] [BepInPlugin("com.morphjne.koreanfontfallback", "Korean Font Fallback", "1.0.0")] public class KoreanFontFallback : BaseUnityPlugin { private static readonly string[] Preferred = new string[2] { "NotoSansKR", "NotoSerifKR" }; private static ManualLogSource _log; private float _timer; private static int _tries; private static TMP_FontAsset _korean; private static int _totalAdded; private void Awake() { _log = ((BaseUnityPlugin)this).Logger; _log.LogInfo((object)"Korean Font Fallback 1.0.0 시작"); } private void Update() { if (_tries > 60) { return; } _timer += Time.deltaTime; if (_timer < 3f) { return; } _timer = 0f; _tries++; try { Apply(); } catch (Exception ex) { _log.LogWarning((object)("폰트 대체 처리 실패: " + ex.Message)); } } private static TMP_FontAsset FindKorean(TMP_FontAsset[] all) { for (int i = 0; i < Preferred.Length; i++) { foreach (TMP_FontAsset val in all) { if (!((Object)(object)val == (Object)null) && ((Object)val).name != null && ((Object)val).name.IndexOf(Preferred[i], StringComparison.OrdinalIgnoreCase) >= 0) { return val; } } } return null; } private static void Apply() { TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>(); if (array == null || array.Length == 0) { return; } if ((Object)(object)_korean == (Object)null) { _korean = FindKorean(array); if ((Object)(object)_korean == (Object)null) { return; } _log.LogInfo((object)("한글 폰트 확보: " + ((Object)_korean).name)); } int num = 0; foreach (TMP_FontAsset val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)_korean) && (((Object)val).name == null || ((Object)val).name.IndexOf("KR", StringComparison.OrdinalIgnoreCase) < 0)) { if (val.fallbackFontAssetTable == null) { val.fallbackFontAssetTable = new List<TMP_FontAsset>(); } if (!val.fallbackFontAssetTable.Contains(_korean)) { val.fallbackFontAssetTable.Add(_korean); num++; } } } try { List<TMP_FontAsset> fallbackFontAssets = TMP_Settings.fallbackFontAssets; if (fallbackFontAssets != null && !fallbackFontAssets.Contains(_korean)) { fallbackFontAssets.Add(_korean); } } catch { } if (num > 0) { _totalAdded += num; _log.LogInfo((object)("폰트 대체 등록 " + num + "개 (누적 " + _totalAdded + ")")); } } }