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 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
|
||||
|
||||
public bool Enabled;
|
||||
@ -117,13 +125,12 @@ namespace UnityExplorer.Hooks
|
||||
if (targetMethod.ReturnType != typeof(void))
|
||||
codeBuilder.Append($", {targetMethod.ReturnType.FullName} __result");
|
||||
|
||||
int paramIdx = 0;
|
||||
var parameters = targetMethod.GetParameters();
|
||||
|
||||
int paramIdx = 0;
|
||||
foreach (var param in parameters)
|
||||
{
|
||||
Type pType = param.ParameterType;
|
||||
if (pType.IsByRef) pType = pType.GetElementType();
|
||||
codeBuilder.Append($", {pType.FullName} __{paramIdx}");
|
||||
codeBuilder.Append($", {param.ParameterType.FullDescription().Replace("&", "")} __{paramIdx}");
|
||||
paramIdx++;
|
||||
}
|
||||
|
||||
@ -177,6 +184,8 @@ namespace UnityExplorer.Hooks
|
||||
|
||||
codeBuilder.AppendLine("}");
|
||||
|
||||
//ExplorerCore.Log(codeBuilder.ToString());
|
||||
|
||||
return PatchSourceCode = codeBuilder.ToString();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user