22 lines
652 B
C#
22 lines
652 B
C#
using System;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace ReFuel.Gltf
|
|
{
|
|
public class GltfJsonConverter : JsonConverter<GltfDocument>
|
|
{
|
|
public override GltfDocument? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
{
|
|
if (typeToConvert != typeof(GltfDocument))
|
|
throw new JsonException();
|
|
|
|
return GltfDocument.OpenJson(ref reader);
|
|
}
|
|
|
|
public override void Write(Utf8JsonWriter writer, GltfDocument value, JsonSerializerOptions options)
|
|
{
|
|
value.Serialize(writer);
|
|
}
|
|
}
|
|
} |