From 1d5f2a953cd03868bd1db2a33a93646d7e3eba01 Mon Sep 17 00:00:00 2001 From: Jonson <596809147@qq.com> Date: Tue, 28 Mar 2023 13:25:32 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AE=E5=A4=8DMonoHook=E5=9C=A82020?= =?UTF-8?q?.3.x=E7=B3=BB=E5=88=97=E7=BC=96=E8=BE=91=E5=99=A8compile?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E6=9C=89=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E5=8F=91=E7=94=9Fhook=E6=B2=A1=E6=9C=89=E5=8F=8A=E6=97=B6?= =?UTF-8?q?=E6=B3=A8=E5=85=A5=E4=BB=8E=E8=80=8C=E5=AF=BC=E8=87=B4=E6=89=93?= =?UTF-8?q?iOS=E5=8C=85=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [fix] 较高版本的Unity GetFunctionPointer不再依赖GUISkin.current,反而高版本unity的GUISkin.current这个值不会立即有值,导致在编辑器compile等时候,hook没有及时注入从而导致打iOS包失败 --------- Co-authored-by: liaoqiang --- Editor/3rds/UnityHook/MethodHook.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Editor/3rds/UnityHook/MethodHook.cs b/Editor/3rds/UnityHook/MethodHook.cs index 0c8173b..f128c85 100644 --- a/Editor/3rds/UnityHook/MethodHook.cs +++ b/Editor/3rds/UnityHook/MethodHook.cs @@ -1,4 +1,4 @@ -/* +/* Desc: 一个可以运行时 Hook Mono 方法的工具,让你可以无需修改 UnityEditor.dll 等文件就可以重写其函数功能 Author: Misaka Mikoto Github: https://github.com/Misaka-Mikoto-Tech/MonoHook @@ -85,7 +85,7 @@ namespace MonoHook private CodePatcher _codePatcher; -#if UNITY_EDITOR +#if UNITY_EDITOR && !UNITY_2020_3_OR_NEWER /// /// call `MethodInfo.MethodHandle.GetFunctionPointer()` /// will visit static class `UnityEditor.IMGUI.Controls.TreeViewGUI.Styles` and invoke its static constructor, @@ -97,7 +97,7 @@ namespace MonoHook static MethodHook() { -#if UNITY_EDITOR +#if UNITY_EDITOR && !UNITY_2020_3_OR_NEWER s_fi_GUISkin_current = typeof(GUISkin).GetField("current", BindingFlags.Static | BindingFlags.NonPublic); #endif } @@ -126,7 +126,7 @@ namespace MonoHook if (isHooked) return; -#if UNITY_EDITOR +#if UNITY_EDITOR && !UNITY_2020_3_OR_NEWER if (s_fi_GUISkin_current.GetValue(null) != null) DoInstall(); else @@ -191,7 +191,7 @@ namespace MonoHook if (targetMethod.IsAbstract) throw new Exception($"WRANING: you can not hook abstract method [{methodName}]"); -#if UNITY_EDITOR +#if UNITY_EDITOR && !UNITY_2020_3_OR_NEWER int minMethodBodySize = 10; { @@ -358,7 +358,7 @@ namespace MonoHook } } -#if UNITY_EDITOR +#if UNITY_EDITOR && !UNITY_2020_3_OR_NEWER private void OnEditorUpdate() { if (s_fi_GUISkin_current.GetValue(null) != null)