PVZFusionTranslation/MelonLoader/Patches/BaseTextObjects/TextMeshPro_Patch.cs
SillyStar-Github 51950bcd76 root rewrite
2025-04-19 13:15:00 -04:00

27 lines
883 B
C#

using HarmonyLib;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
{
[HarmonyPatch(typeof(TextMeshPro))]
public static class TextMeshPro_Patch
{
[HarmonyPatch(nameof(TextMeshPro.OnEnable))]
[HarmonyPostfix]
private static void OnEnable(TextMeshPro __instance)
{
if (!string.IsNullOrEmpty(__instance.text))
{
if (__instance.transform.parent.name.StartsWith("AlmanacHelp"))
{
__instance = StringStore.TranslateText(__instance);
__instance.autoSizeTextContainer = false;
return;
}
__instance = StringStore.TranslateText(__instance);
__instance.autoSizeTextContainer = true;
}
}
}
}