PVZFusionTranslation/MelonLoader/Patches/GameObjects/ButtonObjects/InGameBtn_Patch.cs
SillyStar-Github 22e503bd32 3.6 code
2026-05-01 16:58:57 -04:00

41 lines
1.2 KiB
C#

using HarmonyLib;
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
{
[HarmonyPatch(typeof(InGameBtn))]
public static class InGameBtn_Patch
{
[HarmonyPatch(nameof(InGameBtn.Start))]
[HarmonyPostfix]
private static void Start(InGameBtn __instance)
{
Transform sceneText = __instance.transform.FindChild("SceneText");
if(sceneText != null)
{
TextMeshProUGUI sceneTextTMP = sceneText.transform.GetComponent<TextMeshProUGUI>();
if(sceneTextTMP != null)
{
sceneTextTMP = AssetStore.StringStore.TranslateText(sceneTextTMP);
}
Transform sceneTextShadow = sceneText.transform.FindChild("SceneText");
if(sceneTextShadow != null)
{
TextMeshProUGUI sceneTextShadowTMP = sceneTextShadow.transform.GetComponent<TextMeshProUGUI>();
if (sceneTextShadowTMP != null)
{
sceneTextShadowTMP = AssetStore.StringStore.TranslateText(sceneTextShadowTMP);
}
}
}
foreach(TextMeshProUGUI text in __instance.transform.GetComponentsInChildren<TextMeshProUGUI>())
{
text.text = StringStore.TranslateText(text.text);
}
}
}
}