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

Commit 12cd718

Browse files
committed
3.1.12: store Il2CppToMonoType key as string AssemblyQualifiedName instead of Type object
1 parent 995e2a3 commit 12cd718

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/ExplorerCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace UnityExplorer
1515
public class ExplorerCore
1616
{
1717
public const string NAME = "UnityExplorer";
18-
public const string VERSION = "3.1.11";
18+
public const string VERSION = "3.1.12";
1919
public const string AUTHOR = "Sinai";
2020
public const string GUID = "com.sinai.unityexplorer";
2121

src/Helpers/ReflectionHelpers.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,30 +93,36 @@ public static Type GetActualType(this object obj)
9393
}
9494

9595
#if CPP
96-
private static readonly Dictionary<CppType, Type> Il2CppToMonoType = new Dictionary<CppType, Type>();
96+
private static readonly Dictionary<string, Type> Il2CppToMonoType = new Dictionary<string, Type>();
9797

9898
public static Type GetMonoType(CppType cppType)
9999
{
100-
if (Il2CppToMonoType.ContainsKey(cppType))
101-
return Il2CppToMonoType[cppType];
100+
if (Il2CppToMonoType.ContainsKey(cppType.AssemblyQualifiedName))
101+
return Il2CppToMonoType[cppType.AssemblyQualifiedName];
102102

103103
var getType = Type.GetType(cppType.AssemblyQualifiedName);
104104

105105
if (getType != null)
106106
{
107-
Il2CppToMonoType.Add(cppType, getType);
107+
Il2CppToMonoType.Add(cppType.AssemblyQualifiedName, getType);
108108
return getType;
109109
}
110110
else
111111
{
112112
string baseName = cppType.FullName;
113113
string baseAssembly = cppType.Assembly.GetName().name;
114114

115-
Type unhollowedType = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.GetName().Name == baseAssembly)?.GetTypes().FirstOrDefault(t =>
116-
t.CustomAttributes.Any(ca =>
117-
ca.AttributeType.Name == "ObfuscatedNameAttribute" && (string)ca.ConstructorArguments[0].Value == baseName));
115+
Type unhollowedType = AppDomain.CurrentDomain
116+
.GetAssemblies()
117+
.FirstOrDefault(a => a.GetName().Name == baseAssembly)?
118+
.TryGetTypes()
119+
.FirstOrDefault(t =>
120+
t.CustomAttributes.Any(ca
121+
=> ca.AttributeType.Name == "ObfuscatedNameAttribute"
122+
&& (string)ca.ConstructorArguments[0].Value == baseName));
123+
124+
Il2CppToMonoType.Add(cppType.AssemblyQualifiedName, unhollowedType);
118125

119-
Il2CppToMonoType.Add(cppType, unhollowedType);
120126
return unhollowedType;
121127
}
122128
}

0 commit comments

Comments
 (0)