Fix ambiguous patch exception

This commit is contained in:
Alexejhero authored and js6pak committed 2024-08-17 05:25:48 +02:00
1 parent f55036efbc
commit bbdbd5bec8
1 file changed
+8 -1
+8 -1
View File
@@ -1,4 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using HarmonyLib;
using TMPro;
using UnityEngine;
@@ -8,9 +10,14 @@ namespace Reactor.Patches.Fixes;
/// <summary>
/// "Fixes" an issue where empty TextBoxes have wrong cursor positions.
/// </summary>
[HarmonyPatch(typeof(TextMeshProExtensions), nameof(TextMeshProExtensions.CursorPos))]
[HarmonyPatch]
internal static class CursorPosPatch
{
public static IEnumerable<MethodBase> TargetMethods()
{
return AccessTools.GetDeclaredMethods(typeof(TextMeshProExtensions)).Where(m => m.Name == nameof(TextMeshProExtensions.CursorPos));
}
public static bool Prefix(TextMeshPro self, ref Vector2 __result)
{
if (self.textInfo == null || self.textInfo.lineCount == 0 || self.textInfo.lineInfo[0].characterCount <= 0)