diff --git a/src/ExplorerCore.cs b/src/ExplorerCore.cs index cede49d..8451c8c 100644 --- a/src/ExplorerCore.cs +++ b/src/ExplorerCore.cs @@ -15,7 +15,7 @@ namespace UnityExplorer public class ExplorerCore { public const string NAME = "UnityExplorer"; - public const string VERSION = "3.1.11"; + public const string VERSION = "3.1.12"; public const string AUTHOR = "Sinai"; public const string GUID = "com.sinai.unityexplorer"; diff --git a/src/Helpers/ReflectionHelpers.cs b/src/Helpers/ReflectionHelpers.cs index f136af6..5c7cba4 100644 --- a/src/Helpers/ReflectionHelpers.cs +++ b/src/Helpers/ReflectionHelpers.cs @@ -93,18 +93,18 @@ namespace UnityExplorer.Helpers } #if CPP - private static readonly Dictionary Il2CppToMonoType = new Dictionary(); + private static readonly Dictionary Il2CppToMonoType = new Dictionary(); public static Type GetMonoType(CppType cppType) { - if (Il2CppToMonoType.ContainsKey(cppType)) - return Il2CppToMonoType[cppType]; + if (Il2CppToMonoType.ContainsKey(cppType.AssemblyQualifiedName)) + return Il2CppToMonoType[cppType.AssemblyQualifiedName]; var getType = Type.GetType(cppType.AssemblyQualifiedName); if (getType != null) { - Il2CppToMonoType.Add(cppType, getType); + Il2CppToMonoType.Add(cppType.AssemblyQualifiedName, getType); return getType; } else @@ -112,11 +112,17 @@ namespace UnityExplorer.Helpers string baseName = cppType.FullName; string baseAssembly = cppType.Assembly.GetName().name; - Type unhollowedType = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.GetName().Name == baseAssembly)?.GetTypes().FirstOrDefault(t => - t.CustomAttributes.Any(ca => - ca.AttributeType.Name == "ObfuscatedNameAttribute" && (string)ca.ConstructorArguments[0].Value == baseName)); + Type unhollowedType = AppDomain.CurrentDomain + .GetAssemblies() + .FirstOrDefault(a => a.GetName().Name == baseAssembly)? + .TryGetTypes() + .FirstOrDefault(t => + t.CustomAttributes.Any(ca + => ca.AttributeType.Name == "ObfuscatedNameAttribute" + && (string)ca.ConstructorArguments[0].Value == baseName)); + + Il2CppToMonoType.Add(cppType.AssemblyQualifiedName, unhollowedType); - Il2CppToMonoType.Add(cppType, unhollowedType); return unhollowedType; } }