Error when calling GetEntity or GetEntities for an Entity with an EntityReference property
PixelDough opened this issue · 1 comments
PixelDough commented
I'm using source generation for my LDtk entities to have classes generated from their json objects, but when I try to get an object with an Entity reference as one of it's parameters, the game crashes with this error. If I remove the Entity Reference parameter, it works just fine.
System.NotSupportedException: JsonTypeInfo metadata for type 'LDtk.EntityReference' was not provided by TypeInfoResolver of type 'LDtk.LDtkJsonSourceGenerator'. If using source generation, ensure that all root types passed to the serializer have been annotated with 'JsonSerializableAttribute', along with any types that might be serialized polymorphically.
at System.Text.Json.ThrowHelper.ThrowNotSupportedException_NoMetadataForType(Type type, IJsonTypeInfoResolver resolver)
at System.Text.Json.JsonSerializerOptions.GetTypeInfoInternal(Type type, Boolean ensureConfigured, Nullable`1 ensureNotNull, Boolean resolveIfMutable, Boolean fallBackToNearestAncestorType)
at System.Text.Json.JsonSerializerOptions.GetTypeInfoForRootType(Type type, Boolean fallBackToNearestAncestorType)
at System.Text.Json.JsonSerializer.Deserialize(String json, Type returnType, JsonSerializerOptions options)
at LDtk.LDtkFieldParser.ParseCustomFields[T](T classFields, FieldInstance[] fields, LDtkLevel level)
at LDtk.LDtkFieldParser.ParseCustomEntityFields[T](T entity, FieldInstance[] fields, LDtkLevel level)
at LDtk.LDtkLevel.GetEntityFromInstance[T](EntityInstance entityInstance)
at LDtk.LDtkLevel.GetEntities[T]()
PixelDough commented
Fixed in pull request #30