PVZFusionTranslation/MelonLoader/Patches/GameObjects/TravelLookMenu_Patch.cs
2025-06-04 20:28:59 +07:00

34 lines
No EOL
1.1 KiB
C#

using HarmonyLib;
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
[HarmonyPatch(typeof(TravelLookMenu))]
public static class TravelLookMenu_Patch
{
[HarmonyPatch(nameof(TravelLookMenu.Start))]
[HarmonyPostfix]
private static void Postfix_Start(TravelLookMenu __instance)
{
Transform quitButtonTransform = __instance.transform.Find("Quit");
if (quitButtonTransform != null)
{
TextMeshProUGUI[] allTexts = quitButtonTransform.GetComponentsInChildren<TextMeshProUGUI>(true);
foreach (var textComp in allTexts)
{
if (textComp != null && textComp.text == StringStore.TranslateText("关闭"))
{
textComp.text = StringStore.TranslateText("关闭_close");
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
textComp.font = fontAsset;
}
}
}
}
}
}