Compare commits

...

3 Commits
4.3.1 ... 4.3.2

Author SHA1 Message Date
a80cef4c1d Bump version 2021-09-07 19:11:58 +10:00
450bb77f2e Use Harmony's FullDescription for hook parameter types 2021-09-07 19:11:19 +10:00
0479102db6 Cleanup toggle Enabled logic 2021-09-07 18:06:38 +10:00
2 changed files with 17 additions and 7 deletions

View File

@ -20,7 +20,7 @@ namespace UnityExplorer
public static class ExplorerCore
{
public const string NAME = "UnityExplorer";
public const string VERSION = "4.3.1";
public const string VERSION = "4.3.2";
public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.unityexplorer";

View File

@ -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,13 +184,14 @@ namespace UnityExplorer.Hooks
codeBuilder.AppendLine("}");
//ExplorerCore.Log(codeBuilder.ToString());
return PatchSourceCode = codeBuilder.ToString();
}
public void TogglePatch()
{
Enabled = !Enabled;
if (Enabled)
if (!Enabled)
Patch();
else
Unpatch();
@ -194,6 +202,7 @@ namespace UnityExplorer.Hooks
try
{
patchProcessor.Patch();
Enabled = true;
}
catch (Exception ex)
@ -214,6 +223,7 @@ namespace UnityExplorer.Hooks
patchProcessor.Unpatch(finalizer);
if (transpiler != null)
patchProcessor.Unpatch(transpiler);
Enabled = false;
}
catch (Exception ex)