From dcf0bdce4890232d16b74cdf023cf98e24eb4e7c Mon Sep 17 00:00:00 2001 From: sinaioutlander <49360850+sinaioutlander@users.noreply.github.com> Date: Thu, 19 Nov 2020 00:55:17 +1100 Subject: [PATCH] disabling EventSystem.current patch for bepinex il2cpp as its causing a crash in some games --- src/UI/ForceUnlockCursor.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/UI/ForceUnlockCursor.cs b/src/UI/ForceUnlockCursor.cs index 6bd0773..a68da1d 100644 --- a/src/UI/ForceUnlockCursor.cs +++ b/src/UI/ForceUnlockCursor.cs @@ -77,11 +77,6 @@ namespace UnityExplorer.UI catch { } // Setup Harmony Patches - TryPatch(typeof(EventSystem), - "current", - new HarmonyMethod(typeof(ForceUnlockCursor).GetMethod(nameof(Prefix_EventSystem_set_current))), - true); - TryPatch(typeof(Cursor), "lockState", new HarmonyMethod(typeof(ForceUnlockCursor).GetMethod(nameof(Prefix_set_lockState))), @@ -91,6 +86,17 @@ namespace UnityExplorer.UI "visible", new HarmonyMethod(typeof(ForceUnlockCursor).GetMethod(nameof(Prefix_set_visible))), true); + +#if BIE +#if CPP + // temporarily disabling this patch in BepInEx il2cpp as it's causing a crash in some games. + return; +#endif +#endif + TryPatch(typeof(EventSystem), + "current", + new HarmonyMethod(typeof(ForceUnlockCursor).GetMethod(nameof(Prefix_EventSystem_set_current))), + true); } catch (Exception e) { @@ -120,10 +126,10 @@ namespace UnityExplorer.UI harmony.Patch(prop.GetGetMethod(), postfix: patch); } } - catch // (Exception e) + catch (Exception e) { - //string suf = setter ? "set_" : "get_"; - //ExplorerCore.Log($"Unable to patch {type.Name}.{suf}{property}: {e.Message}"); + string suf = setter ? "set_" : "get_"; + ExplorerCore.Log($"Unable to patch {type.Name}.{suf}{property}: {e.Message}"); } }