Compare commits

..

3 Commits
2.0.8 ... 2.1.0

Author SHA1 Message Date
f4ba14cd13 2.1.0
* Fix a bug with Il2Cpp reflection causing TargetInvocationException and other weird issues.
2020-10-30 19:24:42 +11:00
4263cef26a Update ExplorerCore.cs 2020-10-28 20:49:53 +11:00
626e680510 2.0.9
* Fix an issue in mono builds causing a crash
* Fix for games which only contain one scene
* A few small cleanups
2020-10-28 20:49:18 +11:00
9 changed files with 43 additions and 17 deletions

View File

@ -25,7 +25,7 @@
<RootNamespace>Explorer</RootNamespace> <RootNamespace>Explorer</RootNamespace>
<AssemblyName>Explorer</AssemblyName> <AssemblyName>Explorer</AssemblyName>
<!-- Set this to the MelonLoader Il2Cpp Game folder, without the ending '\' character. --> <!-- Set this to the MelonLoader Il2Cpp Game folder, without the ending '\' character. -->
<MLCppGameFolder>D:\Steam\steamapps\common\Hellpoint</MLCppGameFolder> <MLCppGameFolder>D:\Steam\steamapps\common\VRChat</MLCppGameFolder>
<!-- Set this to the MelonLoader Mono Game folder, without the ending '\' character. --> <!-- Set this to the MelonLoader Mono Game folder, without the ending '\' character. -->
<MLMonoGameFolder>D:\Steam\steamapps\common\Outward</MLMonoGameFolder> <MLMonoGameFolder>D:\Steam\steamapps\common\Outward</MLMonoGameFolder>
<!-- Set this to the BepInEx Il2Cpp Game folder, without the ending '\' character. --> <!-- Set this to the BepInEx Il2Cpp Game folder, without the ending '\' character. -->

View File

@ -12,7 +12,7 @@ namespace Explorer
public class ExplorerCore public class ExplorerCore
{ {
public const string NAME = "Explorer " + VERSION + " (" + PLATFORM + ", " + MODLOADER + ")"; public const string NAME = "Explorer " + VERSION + " (" + PLATFORM + ", " + MODLOADER + ")";
public const string VERSION = "2.0.8"; public const string VERSION = "2.1.0";
public const string AUTHOR = "Sinai"; public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.explorer"; public const string GUID = "com.sinai.explorer";

View File

@ -43,7 +43,7 @@ namespace Explorer.Helpers
return obj; return obj;
if (!typeof(Il2CppSystem.Object).IsAssignableFrom(castTo)) if (!typeof(Il2CppSystem.Object).IsAssignableFrom(castTo))
return obj; return obj as System.Object;
IntPtr castToPtr; IntPtr castToPtr;
if (!ClassPointers.ContainsKey(castTo)) if (!ClassPointers.ContainsKey(castTo))

View File

@ -49,6 +49,7 @@ namespace Explorer.Tests
#if CPP #if CPP
public static Il2CppSystem.Collections.Generic.HashSet<string> ILHashSetTest; public static Il2CppSystem.Collections.Generic.HashSet<string> ILHashSetTest;
public static Il2CppReferenceArray<Il2CppSystem.Object> testRefArray;
#endif #endif
public TestClass() public TestClass()
@ -64,6 +65,12 @@ namespace Explorer.Tests
GameObject.DontDestroyOnLoad(TestTexture); GameObject.DontDestroyOnLoad(TestTexture);
GameObject.DontDestroyOnLoad(TestSprite); GameObject.DontDestroyOnLoad(TestSprite);
testRefArray = new Il2CppReferenceArray<Il2CppSystem.Object>(5);
for (int i = 0; i < 5; i++)
{
testRefArray[i] = "hi " + i;
}
//// test loading a tex from file //// test loading a tex from file
//var dataToLoad = System.IO.File.ReadAllBytes(@"Mods\Explorer\Tex_Nemundis_Nebula.png"); //var dataToLoad = System.IO.File.ReadAllBytes(@"Mods\Explorer\Tex_Nemundis_Nebula.png");
//ExplorerCore.Log($"Tex load success: {TestTexture.LoadImage(dataToLoad, false)}"); //ExplorerCore.Log($"Tex load success: {TestTexture.LoadImage(dataToLoad, false)}");

View File

@ -43,15 +43,14 @@ namespace Explorer.UI
// Get current cursor state and enable cursor // Get current cursor state and enable cursor
try try
{ {
//m_lastLockMode = Cursor.lockState; m_lastLockMode = (CursorLockMode)typeof(Cursor).GetProperty("lockState", BF.Public | BF.Static).GetValue(null, null);
m_lastLockMode = (CursorLockMode?)typeof(Cursor).GetProperty("lockState", BF.Public | BF.Static)?.GetValue(null, null) m_lastVisibleState = (bool)typeof(Cursor).GetProperty("visible", BF.Public | BF.Static).GetValue(null, null);
?? CursorLockMode.None; }
catch
//m_lastVisibleState = Cursor.visible; {
m_lastVisibleState = (bool?)typeof(Cursor).GetProperty("visible", BF.Public | BF.Static)?.GetValue(null, null) m_lastLockMode = CursorLockMode.None;
?? false; m_lastVisibleState = true;
} }
catch { }
// Setup Harmony Patches // Setup Harmony Patches
TryPatch("lockState", new HarmonyMethod(typeof(ForceUnlockCursor).GetMethod(nameof(Prefix_set_lockState))), true); TryPatch("lockState", new HarmonyMethod(typeof(ForceUnlockCursor).GetMethod(nameof(Prefix_set_lockState))), true);

View File

@ -10,6 +10,7 @@ using Explorer.UI.Inspectors;
using Explorer.Helpers; using Explorer.Helpers;
#if CPP #if CPP
using UnhollowerBaseLib; using UnhollowerBaseLib;
using UnhollowerRuntimeLib;
#endif #endif
namespace Explorer.UI.Inspectors namespace Explorer.UI.Inspectors
@ -141,6 +142,18 @@ namespace Explorer.UI.Inspectors
continue; continue;
} }
var target = Target;
#if CPP
try
{
target = target.Il2CppCast(declaringType);
}
catch //(Exception e)
{
//ExplorerCore.LogWarning("Excepting casting " + target.GetType().FullName + " to " + declaringType.FullName);
}
#endif
foreach (var member in infos) foreach (var member in infos)
{ {
try try
@ -150,14 +163,13 @@ namespace Explorer.UI.Inspectors
if (m < 4 || m > 16) if (m < 4 || m > 16)
continue; continue;
var fi = member as FieldInfo;
var pi = member as PropertyInfo; var pi = member as PropertyInfo;
var mi = member as MethodInfo; var mi = member as MethodInfo;
if (IsStaticInspector) if (IsStaticInspector)
{ {
if (fi != null && !fi.IsStatic) continue; if (member is FieldInfo fi && !fi.IsStatic) continue;
else if (pi != null && !pi.GetAccessors()[0].IsStatic) continue; else if (pi != null && !pi.GetAccessors(true)[0].IsStatic) continue;
else if (mi != null && !mi.IsStatic) continue; else if (mi != null && !mi.IsStatic) continue;
} }
@ -195,7 +207,9 @@ namespace Explorer.UI.Inspectors
try try
{ {
var cached = CacheFactory.GetCacheObject(member, Target); // ExplorerCore.Log($"Trying to cache member {sig}...");
var cached = CacheFactory.GetCacheObject(member, target);
if (cached != null) if (cached != null)
{ {

View File

@ -11,6 +11,11 @@ namespace Explorer.UI
{ {
private Sprite refSprite; private Sprite refSprite;
public override void Init()
{
base.Init();
}
public override void UpdateValue() public override void UpdateValue()
{ {
#if CPP #if CPP
@ -30,7 +35,7 @@ namespace Explorer.UI
public override void GetTexture2D() public override void GetTexture2D()
{ {
if (refSprite) if (refSprite && refSprite.texture)
{ {
currentTex = refSprite.texture; currentTex = refSprite.texture;
} }

View File

@ -35,6 +35,7 @@ namespace Explorer.UI.Main
public override void Init() public override void Init()
{ {
Instance = this; Instance = this;
m_currentScene = UnityHelpers.ActiveSceneName;
} }
public void OnSceneChange() public void OnSceneChange()

View File

@ -18,7 +18,7 @@ namespace Explorer
#if CPP #if CPP
return GUIUnstrip.ExpandWidth(expand); return GUIUnstrip.ExpandWidth(expand);
#else #else
return GUIHelper.ExpandWidth(expand); return GUILayout.ExpandWidth(expand);
#endif #endif
} }