@@ -93,30 +93,36 @@ public static Type GetActualType(this object obj)
93
93
}
94
94
95
95
#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 > ( ) ;
97
97
98
98
public static Type GetMonoType ( CppType cppType )
99
99
{
100
- if ( Il2CppToMonoType . ContainsKey ( cppType ) )
101
- return Il2CppToMonoType [ cppType ] ;
100
+ if ( Il2CppToMonoType . ContainsKey ( cppType . AssemblyQualifiedName ) )
101
+ return Il2CppToMonoType [ cppType . AssemblyQualifiedName ] ;
102
102
103
103
var getType = Type . GetType ( cppType . AssemblyQualifiedName ) ;
104
104
105
105
if ( getType != null )
106
106
{
107
- Il2CppToMonoType . Add ( cppType , getType ) ;
107
+ Il2CppToMonoType . Add ( cppType . AssemblyQualifiedName , getType ) ;
108
108
return getType ;
109
109
}
110
110
else
111
111
{
112
112
string baseName = cppType . FullName ;
113
113
string baseAssembly = cppType . Assembly . GetName ( ) . name ;
114
114
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 ) ;
118
125
119
- Il2CppToMonoType . Add ( cppType , unhollowedType ) ;
120
126
return unhollowedType ;
121
127
}
122
128
}
0 commit comments