[fix] 修复MonoHook在2020.3.x系列编辑器compile的时候,有可能发生hook没有及时注入从而导致打iOS包失败
[fix] 较高版本的Unity GetFunctionPointer不再依赖GUISkin.current,反而高版本unity的GUISkin.current这个值不会立即有值,导致在编辑器compile等时候,hook没有及时注入从而导致打iOS包失败 --------- Co-authored-by: liaoqiang <liaoqiang@nibirutech.com>main
parent
75cb53cb19
commit
1d5f2a953c
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
Desc: 一个可以运行时 Hook Mono 方法的工具,让你可以无需修改 UnityEditor.dll 等文件就可以重写其函数功能
|
Desc: 一个可以运行时 Hook Mono 方法的工具,让你可以无需修改 UnityEditor.dll 等文件就可以重写其函数功能
|
||||||
Author: Misaka Mikoto
|
Author: Misaka Mikoto
|
||||||
Github: https://github.com/Misaka-Mikoto-Tech/MonoHook
|
Github: https://github.com/Misaka-Mikoto-Tech/MonoHook
|
||||||
|
@ -85,7 +85,7 @@ namespace MonoHook
|
||||||
|
|
||||||
private CodePatcher _codePatcher;
|
private CodePatcher _codePatcher;
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR && !UNITY_2020_3_OR_NEWER
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// call `MethodInfo.MethodHandle.GetFunctionPointer()`
|
/// call `MethodInfo.MethodHandle.GetFunctionPointer()`
|
||||||
/// will visit static class `UnityEditor.IMGUI.Controls.TreeViewGUI.Styles` and invoke its static constructor,
|
/// will visit static class `UnityEditor.IMGUI.Controls.TreeViewGUI.Styles` and invoke its static constructor,
|
||||||
|
@ -97,7 +97,7 @@ namespace MonoHook
|
||||||
|
|
||||||
static MethodHook()
|
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);
|
s_fi_GUISkin_current = typeof(GUISkin).GetField("current", BindingFlags.Static | BindingFlags.NonPublic);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ namespace MonoHook
|
||||||
if (isHooked)
|
if (isHooked)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR && !UNITY_2020_3_OR_NEWER
|
||||||
if (s_fi_GUISkin_current.GetValue(null) != null)
|
if (s_fi_GUISkin_current.GetValue(null) != null)
|
||||||
DoInstall();
|
DoInstall();
|
||||||
else
|
else
|
||||||
|
@ -191,7 +191,7 @@ namespace MonoHook
|
||||||
if (targetMethod.IsAbstract)
|
if (targetMethod.IsAbstract)
|
||||||
throw new Exception($"WRANING: you can not hook abstract method [{methodName}]");
|
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;
|
int minMethodBodySize = 10;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -358,7 +358,7 @@ namespace MonoHook
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR && !UNITY_2020_3_OR_NEWER
|
||||||
private void OnEditorUpdate()
|
private void OnEditorUpdate()
|
||||||
{
|
{
|
||||||
if (s_fi_GUISkin_current.GetValue(null) != null)
|
if (s_fi_GUISkin_current.GetValue(null) != null)
|
||||||
|
|
Loading…
Reference in New Issue