@@ -389,22 +389,37 @@ static UnityEventBase GetDummyEvent(SerializedProperty prop)
389389 if ( tgtobj == null )
390390 return new UnityEvent ( ) ;
391391
392- string propPath = prop . propertyPath ;
392+ UnityEventBase ret = null ;
393393 Type ft = tgtobj . GetType ( ) ;
394+ var bindflags = BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic ;
395+ do
396+ {
397+ ret = GetDummyEventHelper ( prop . propertyPath , ft , bindflags ) ;
398+ //no need to look for public members again since the base type covered that
399+ bindflags = BindingFlags . Instance | BindingFlags . NonPublic ;
400+ ft = ft . BaseType ;
401+ }
402+ while ( ret == null && ft != null ) ;
403+ // go up the class hierarchy if it exists and the property is not found on the child
404+ return ( ret == null ) ? new UnityEvent ( ) : ret ;
405+ }
406+
407+ private static UnityEventBase GetDummyEventHelper ( string propPath , Type targetObjectType , BindingFlags flags )
408+ {
394409 while ( propPath . Length != 0 )
395410 {
396411 //we could have a leftover '.' if the previous iteration handled an array element
397412 if ( propPath . StartsWith ( "." ) )
398413 propPath = propPath . Substring ( 1 ) ;
399414
400415 var splits = propPath . Split ( new [ ] { '.' } , 2 ) ;
401- var newField = ft . GetField ( splits [ 0 ] , BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic ) ;
416+ var newField = targetObjectType . GetField ( splits [ 0 ] , flags ) ;
402417 if ( newField == null )
403418 break ;
404419
405- ft = newField . FieldType ;
406- if ( ft . IsArrayOrList ( ) )
407- ft = ft . GetArrayOrListElementType ( ) ;
420+ targetObjectType = newField . FieldType ;
421+ if ( targetObjectType . IsArrayOrList ( ) )
422+ targetObjectType = targetObjectType . GetArrayOrListElementType ( ) ;
408423
409424 //the last item in the property path could have been an array element
410425 //bail early in that case
@@ -415,9 +430,9 @@ static UnityEventBase GetDummyEvent(SerializedProperty prop)
415430 if ( propPath . StartsWith ( "Array.data[" ) )
416431 propPath = propPath . Split ( new [ ] { ']' } , 2 ) [ 1 ] ;
417432 }
418- if ( ft . IsSubclassOf ( typeof ( UnityEventBase ) ) )
419- return Activator . CreateInstance ( ft ) as UnityEventBase ;
420- return new UnityEvent ( ) ;
433+ if ( targetObjectType . IsSubclassOf ( typeof ( UnityEventBase ) ) )
434+ return Activator . CreateInstance ( targetObjectType ) as UnityEventBase ;
435+ return null ;
421436 }
422437
423438 struct ValidMethodMap
0 commit comments