mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 22:27:45 +08:00
Use Harmony's FullDescription for hook parameter types
This commit is contained in:
parent
0479102db6
commit
450bb77f2e
@ -17,6 +17,14 @@ namespace UnityExplorer.Hooks
|
|||||||
private static readonly StringBuilder evalOutput = new StringBuilder();
|
private static readonly StringBuilder evalOutput = new StringBuilder();
|
||||||
private static readonly ScriptEvaluator scriptEvaluator = new ScriptEvaluator(new StringWriter(evalOutput));
|
private static readonly ScriptEvaluator scriptEvaluator = new ScriptEvaluator(new StringWriter(evalOutput));
|
||||||
|
|
||||||
|
static HookInstance()
|
||||||
|
{
|
||||||
|
scriptEvaluator.Run("using System;");
|
||||||
|
scriptEvaluator.Run("using System.Reflection;");
|
||||||
|
scriptEvaluator.Run("using System.Collections;");
|
||||||
|
scriptEvaluator.Run("using System.Collections.Generic;");
|
||||||
|
}
|
||||||
|
|
||||||
// Instance
|
// Instance
|
||||||
|
|
||||||
public bool Enabled;
|
public bool Enabled;
|
||||||
@ -117,13 +125,12 @@ namespace UnityExplorer.Hooks
|
|||||||
if (targetMethod.ReturnType != typeof(void))
|
if (targetMethod.ReturnType != typeof(void))
|
||||||
codeBuilder.Append($", {targetMethod.ReturnType.FullName} __result");
|
codeBuilder.Append($", {targetMethod.ReturnType.FullName} __result");
|
||||||
|
|
||||||
int paramIdx = 0;
|
|
||||||
var parameters = targetMethod.GetParameters();
|
var parameters = targetMethod.GetParameters();
|
||||||
|
|
||||||
|
int paramIdx = 0;
|
||||||
foreach (var param in parameters)
|
foreach (var param in parameters)
|
||||||
{
|
{
|
||||||
Type pType = param.ParameterType;
|
codeBuilder.Append($", {param.ParameterType.FullDescription().Replace("&", "")} __{paramIdx}");
|
||||||
if (pType.IsByRef) pType = pType.GetElementType();
|
|
||||||
codeBuilder.Append($", {pType.FullName} __{paramIdx}");
|
|
||||||
paramIdx++;
|
paramIdx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,6 +184,8 @@ namespace UnityExplorer.Hooks
|
|||||||
|
|
||||||
codeBuilder.AppendLine("}");
|
codeBuilder.AppendLine("}");
|
||||||
|
|
||||||
|
//ExplorerCore.Log(codeBuilder.ToString());
|
||||||
|
|
||||||
return PatchSourceCode = codeBuilder.ToString();
|
return PatchSourceCode = codeBuilder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user