Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 113f2fd

Browse files
committed
3.3.5 - fix Il2Cpp Hashtable, boxed strings
1 parent 7443f65 commit 113f2fd

27 files changed

+133
-68
lines changed

src/Core/CSharp/ScriptInteraction.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using UnityExplorer.Core.Runtime;
88
using UnityExplorer.UI.Main.CSConsole;
99
using UnityExplorer.UI.Main.Home;
10+
using UnityExplorer.UI.Inspectors;
1011

1112
namespace UnityExplorer.Core.CSharp
1213
{

src/Core/ReflectionUtility.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using BF = System.Reflection.BindingFlags;
88
using UnityExplorer.Core.Runtime;
99

10-
namespace UnityExplorer.Core
10+
namespace UnityExplorer
1111
{
1212
public static class ReflectionUtility
1313
{
@@ -18,7 +18,7 @@ public static class ReflectionUtility
1818
/// </summary>
1919
/// <param name="obj">The object to get the true Type for.</param>
2020
/// <returns>The most accurate Type of the object which could be identified.</returns>
21-
public static Type GetType(this object obj)
21+
public static Type GetActualType(this object obj)
2222
{
2323
if (obj == null)
2424
return null;
@@ -32,7 +32,7 @@ public static Type GetType(this object obj)
3232
/// <param name="obj">The object to cast</param>
3333
/// <returns>The object, cast to the underlying Type if possible, otherwise the original object.</returns>
3434
public static object Cast(this object obj)
35-
=> ReflectionProvider.Instance.Cast(obj, GetType(obj));
35+
=> ReflectionProvider.Instance.Cast(obj, GetActualType(obj));
3636

3737
/// <summary>
3838
/// Cast an object to a Type, if possible.
@@ -105,7 +105,7 @@ from type in asm.TryGetTypes()
105105
/// <summary>
106106
/// Get all base types of the provided Type, including itself.
107107
/// </summary>
108-
public static Type[] GetAllBaseTypes(this object obj) => GetAllBaseTypes(GetType(obj));
108+
public static Type[] GetAllBaseTypes(this object obj) => GetAllBaseTypes(GetActualType(obj));
109109

110110
/// <summary>
111111
/// Get all base types of the provided Type, including itself.

src/Core/Runtime/Il2Cpp/Il2CppReflection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public static object Il2CppCast(object obj, Type castTo)
163163
IntPtr castFromPtr = il2cpp_object_get_class(ilObj.Pointer);
164164

165165
if (!il2cpp_class_is_assignable_from(castToPtr, castFromPtr))
166-
return obj;
166+
return null;
167167

168168
if (RuntimeSpecificsStore.IsInjected(castToPtr))
169169
return UnhollowerBaseLib.Runtime.ClassInjectorBase.GetMonoObjectFromIl2CppPointer(ilObj.Pointer);

src/Core/TestClass.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace UnityExplorer
7+
{
8+
#if CPP
9+
public static class TestClass
10+
{
11+
public static Il2CppSystem.Collections.Hashtable testHashset;
12+
13+
static TestClass()
14+
{
15+
testHashset = new Il2CppSystem.Collections.Hashtable();
16+
testHashset.Add("key1", "itemOne");
17+
testHashset.Add("key2", "itemTwo");
18+
testHashset.Add("key3", "itemThree");
19+
}
20+
}
21+
#endif
22+
}

src/ExplorerCore.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace UnityExplorer
1212
public class ExplorerCore
1313
{
1414
public const string NAME = "UnityExplorer";
15-
public const string VERSION = "3.3.4";
15+
public const string VERSION = "3.3.5";
1616
public const string AUTHOR = "Sinai";
1717
public const string GUID = "com.sinai.unityexplorer";
1818

@@ -46,6 +46,8 @@ public static void Init(IExplorerLoader loader)
4646
UIManager.Init();
4747

4848
Log($"{NAME} {VERSION} initialized.");
49+
50+
// InspectorManager.Instance.Inspect(typeof(TestClass));
4951
}
5052

5153
public static void Update()

src/Loader/ML/MelonLoaderConfigHandler.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ public override void Init()
2121
{
2222
prefCategory = MelonPreferences.CreateCategory(CTG_NAME, $"{CTG_NAME} Settings");
2323

24-
MelonPreferences.Mapper.RegisterMapper(KeycodeReader, KeycodeWriter);
24+
try
25+
{
26+
MelonPreferences.Mapper.RegisterMapper(KeycodeReader, KeycodeWriter);
27+
}
28+
catch { }
2529
}
2630

2731
public override void LoadConfig()

src/UI/CacheObject/CacheMember.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
using UnityExplorer.Core;
1111
using UnityExplorer.UI.Utility;
1212
using UnityExplorer.UI.InteractiveValues;
13-
using UnityExplorer.UI.Main.Home.Inspectors.Reflection;
13+
using UnityExplorer.UI.Inspectors.Reflection;
1414

1515
namespace UnityExplorer.UI.CacheObject
1616
{
@@ -86,15 +86,15 @@ public override void UpdateValue()
8686
{
8787
try
8888
{
89-
Type baseType = ReflectionUtility.GetType(IValue.Value) ?? FallbackType;
89+
Type baseType = ReflectionUtility.GetActualType(IValue.Value) ?? FallbackType;
9090

9191
if (!ReflectionProvider.Instance.IsReflectionSupported(baseType))
9292
throw new Exception("Type not supported with reflection");
9393

9494
UpdateReflection();
9595

9696
if (IValue.Value != null)
97-
IValue.Value = IValue.Value.Cast(ReflectionUtility.GetType(IValue.Value));
97+
IValue.Value = IValue.Value.Cast(ReflectionUtility.GetActualType(IValue.Value));
9898
}
9999
catch (Exception e)
100100
{

src/UI/CacheObject/CacheObjectBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public virtual void UpdateValue()
5555
// if the type has changed fundamentally, make a new interactivevalue for it
5656
var type = value == null
5757
? FallbackType
58-
: ReflectionUtility.GetType(value);
58+
: ReflectionUtility.GetActualType(value);
5959

6060
var ivalueType = InteractiveValue.GetIValueForType(type);
6161

src/UI/Main/Home/Inspectors/GameObjects/ChildList.cs renamed to src/UI/Inspectors/GameObjects/ChildList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using UnityExplorer.Core.Runtime;
88
using UnityExplorer.UI.Utility;
99

10-
namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
10+
namespace UnityExplorer.UI.Inspectors.GameObjects
1111
{
1212
public class ChildList
1313
{

src/UI/Main/Home/Inspectors/GameObjects/ComponentList.cs renamed to src/UI/Inspectors/GameObjects/ComponentList.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
using UnityExplorer.Core.Runtime;
99
using UnityExplorer.UI.Utility;
1010

11-
namespace UnityExplorer.UI.Main.Home.Inspectors.GameObjects
11+
namespace UnityExplorer.UI.Inspectors.GameObjects
1212
{
1313
public class ComponentList
1414
{
@@ -75,7 +75,7 @@ internal void RefreshComponentList()
7575

7676
var text = s_compListTexts[i];
7777

78-
text.text = SignatureHighlighter.ParseFullSyntax(ReflectionUtility.GetType(comp), true);
78+
text.text = SignatureHighlighter.ParseFullSyntax(ReflectionUtility.GetActualType(comp), true);
7979

8080
var toggle = s_compToggles[i];
8181
#if CPP

0 commit comments

Comments
 (0)