mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-14 15:46:36 +08:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
a80cef4c1d | |||
450bb77f2e | |||
0479102db6 |
@ -20,7 +20,7 @@ namespace UnityExplorer
|
|||||||
public static class ExplorerCore
|
public static class ExplorerCore
|
||||||
{
|
{
|
||||||
public const string NAME = "UnityExplorer";
|
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 AUTHOR = "Sinai";
|
||||||
public const string GUID = "com.sinai.unityexplorer";
|
public const string GUID = "com.sinai.unityexplorer";
|
||||||
|
|
||||||
|
@ -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,13 +184,14 @@ namespace UnityExplorer.Hooks
|
|||||||
|
|
||||||
codeBuilder.AppendLine("}");
|
codeBuilder.AppendLine("}");
|
||||||
|
|
||||||
|
//ExplorerCore.Log(codeBuilder.ToString());
|
||||||
|
|
||||||
return PatchSourceCode = codeBuilder.ToString();
|
return PatchSourceCode = codeBuilder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TogglePatch()
|
public void TogglePatch()
|
||||||
{
|
{
|
||||||
Enabled = !Enabled;
|
if (!Enabled)
|
||||||
if (Enabled)
|
|
||||||
Patch();
|
Patch();
|
||||||
else
|
else
|
||||||
Unpatch();
|
Unpatch();
|
||||||
@ -194,6 +202,7 @@ namespace UnityExplorer.Hooks
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
patchProcessor.Patch();
|
patchProcessor.Patch();
|
||||||
|
|
||||||
Enabled = true;
|
Enabled = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -214,6 +223,7 @@ namespace UnityExplorer.Hooks
|
|||||||
patchProcessor.Unpatch(finalizer);
|
patchProcessor.Unpatch(finalizer);
|
||||||
if (transpiler != null)
|
if (transpiler != null)
|
||||||
patchProcessor.Unpatch(transpiler);
|
patchProcessor.Unpatch(transpiler);
|
||||||
|
|
||||||
Enabled = false;
|
Enabled = false;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
Reference in New Issue
Block a user