mirror of
https://github.com/codewriter-packages/Tri-Inspector.git
synced 2025-01-22 00:08:51 -05:00
Fix SerializeReference on non serializable collections (#167)
This commit is contained in:
parent
6c844f0b69
commit
f2a652a75f
@ -27,7 +27,27 @@ namespace TriInspector.Utilities
|
||||
|
||||
if (fieldInfo.GetCustomAttribute<SerializeReference>() != null)
|
||||
{
|
||||
return true;
|
||||
// if it's a list or array, the base type should be serializable
|
||||
if (fieldInfo.FieldType.IsArray)
|
||||
{
|
||||
var type = fieldInfo.FieldType.GetElementType();
|
||||
if (type.IsSerializable || type.IsInterface)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else if (fieldInfo.FieldType.IsGenericType && fieldInfo.FieldType.GetGenericTypeDefinition() == typeof(List<>))
|
||||
{
|
||||
var type = fieldInfo.FieldType.GenericTypeArguments[0];
|
||||
if (type.IsSerializable || type.IsInterface)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldInfo.IsPublic || fieldInfo.GetCustomAttribute<SerializeField>() != null)
|
||||
|
Loading…
Reference in New Issue
Block a user