@@ -253,7 +253,7 @@ internal static FieldInfo GetFieldInfo(this SerializedProperty property, out Typ
253253
254254 internal static FieldInfo GetFieldInfo ( this SerializedProperty property , out Type propertyType , Object target )
255255 {
256- return GetFieldInfoFromProperty ( target . GetType ( ) , property . propertyPath , out propertyType ) ;
256+ return GetFieldInfoFromProperty ( property , out propertyType , target . GetType ( ) ) ;
257257 }
258258
259259 public static FieldInfo GetFieldInfoFromProperty ( SerializedProperty property , out Type type )
@@ -265,14 +265,15 @@ public static FieldInfo GetFieldInfoFromProperty(SerializedProperty property, ou
265265 return null ;
266266 }
267267
268- return GetFieldInfoFromProperty ( classType , property . propertyPath , out type ) ;
268+ return GetFieldInfoFromProperty ( property , out type , classType ) ;
269269 }
270270
271- public static FieldInfo GetFieldInfoFromProperty ( Type host , string fieldPath , out Type type )
271+ public static FieldInfo GetFieldInfoFromProperty ( SerializedProperty property , out Type type , Type host )
272272 {
273273 FieldInfo field = null ;
274274 type = host ;
275275
276+ var fieldPath = property . propertyPath ;
276277 var members = GetPropertyFieldTree ( fieldPath , false ) ;
277278 for ( var i = 0 ; i < members . Length ; i ++ )
278279 {
@@ -287,10 +288,21 @@ public static FieldInfo GetFieldInfoFromProperty(Type host, string fieldPath, ou
287288 continue ;
288289 }
289290
291+ const BindingFlags fieldFlags = BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic ;
290292 FieldInfo foundField = null ;
291293 for ( var currentType = type ; foundField == null && currentType != null ; currentType = currentType . BaseType )
292294 {
293- foundField = currentType . GetField ( member , BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic ) ;
295+ foundField = currentType . GetField ( member , fieldFlags ) ;
296+ //NOTE: [SerializeReference] detected? If so we need to check dynamically cached type
297+ if ( foundField == null )
298+ {
299+ var parent = property . GetParent ( ) ;
300+ if ( parent != null && parent . propertyType == SerializedPropertyType . ManagedReference )
301+ {
302+ TypeUtilities . TryGetTypeFromManagedReferenceFullTypeName ( parent . managedReferenceFullTypename , out var parentType ) ;
303+ foundField = parentType . GetField ( member , fieldFlags ) ;
304+ }
305+ }
294306 }
295307
296308 if ( foundField == null )
0 commit comments