Set 'ExplicitIgnorableItemLength = 0' to glTF elements to export models without errors

This commit is contained in:
yutopp 2019-01-31 15:31:16 +09:00
parent 28562ec3f1
commit 1d0c2d8840
2 changed files with 24 additions and 4 deletions

View File

@ -575,6 +575,26 @@ namespace UniGLTF
Assert.AreEqual("[version.String] null", ex.Message);
}
[Test]
public void GLTFTest()
{
var model = new glTF()
{
asset = new glTFAssets()
{
version = "0.49",
},
extensions = null,
};
var c = new JsonSchemaValidationContext("")
{
EnableDiagnosisForNotRequiredFields = true,
};
var json2 = JsonSchema.FromType<glTF>().Serialize(model, c);
Assert.AreEqual(@"{""asset"":{""version"":""0.49""},""extras"":{}}", json2);
}
[Test]
public void SameMeshButDifferentMaterialExport()
{

View File

@ -31,7 +31,7 @@ namespace UniGLTF
public glTFAssets asset = new glTFAssets();
#region Buffer
[JsonSchema(MinItems = 1)]
[JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)]
public List<glTFBuffer> buffers = new List<glTFBuffer>();
public int AddBuffer(IBytesBuffer bytesBuffer)
{
@ -40,7 +40,7 @@ namespace UniGLTF
return index;
}
[JsonSchema(MinItems = 1)]
[JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)]
public List<glTFBufferView> bufferViews = new List<glTFBufferView>();
public int AddBufferView(glTFBufferView view)
{
@ -49,7 +49,7 @@ namespace UniGLTF
return index;
}
[JsonSchema(MinItems = 1)]
[JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)]
public List<glTFAccessor> accessors = new List<glTFAccessor>();
T[] GetAttrib<T>(glTFAccessor accessor, glTFBufferView view) where T : struct
@ -212,7 +212,7 @@ namespace UniGLTF
return samplers[index];
}
[JsonSchema(MinItems = 1)]
[JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)]
public List<glTFImage> images = new List<glTFImage>();
public int GetImageIndexFromTextureIndex(int textureIndex)