mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-23 00:52:31 +08:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
a80cef4c1d | |||
450bb77f2e | |||
0479102db6 |
@ -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";
|
||||
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user