File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,27 @@ public static bool IsSerializableByUnity(FieldInfo fieldInfo)
2727
2828 if ( fieldInfo . GetCustomAttribute < SerializeReference > ( ) != null )
2929 {
30- return true ;
30+ // if it's a list or array, the base type should be serializable
31+ if ( fieldInfo . FieldType . IsArray )
32+ {
33+ var type = fieldInfo . FieldType . GetElementType ( ) ;
34+ if ( type . IsSerializable || type . IsInterface )
35+ return true ;
36+ else
37+ return false ;
38+ }
39+ else if ( fieldInfo . FieldType . IsGenericType && fieldInfo . FieldType . GetGenericTypeDefinition ( ) == typeof ( List < > ) )
40+ {
41+ var type = fieldInfo . FieldType . GenericTypeArguments [ 0 ] ;
42+ if ( type . IsSerializable || type . IsInterface )
43+ return true ;
44+ else
45+ return false ;
46+ }
47+ else
48+ {
49+ return true ;
50+ }
3151 }
3252
3353 if ( fieldInfo . IsPublic || fieldInfo . GetCustomAttribute < SerializeField > ( ) != null )
You can’t perform that action at this time.
0 commit comments