Add schemaVersion field to VRM extensions

This commit is contained in:
yutopp 2019-02-01 20:04:00 +09:00
parent 0b0e511100
commit 6c2da9704a
4 changed files with 46 additions and 0 deletions

View File

@ -617,6 +617,27 @@ namespace VRM
Assert.AreEqual(json,json2);
}
[Test]
public void ExtensionsTest()
{
var model = new glTF_VRM_extensions()
{
meta = null,
humanoid = null,
firstPerson = null,
blendShapeMaster = null,
secondaryAnimation = null,
materialProperties = null,
};
var c = new JsonSchemaValidationContext("")
{
EnableDiagnosisForNotRequiredFields = true,
};
var json2 = JsonSchema.FromType<glTF_VRM_extensions>().Serialize(model, c);
Assert.AreEqual(@"{""exporterVersion"":""UniVRM-0.50"",""schemaVersion"":""0.0""}",json2);
}
// TODO: Move to another suitable location
T deserialize<T>(string json)
{

View File

@ -37,6 +37,9 @@ VRM extension is for 3d humanoid avatars (and models) in VR applications.
[JsonSchema(Description = @"Version of exporter that vrm created. " + VRMVersion.VRM_VERSION)]
public string exporterVersion = "UniVRM-" + VRMVersion.VERSION;
[JsonSchema(Description = @"Version of JSON Schema for VRM")]
public string schemaVersion = VRMSchemaVersion.Version;
public glTF_VRM_Meta meta = new glTF_VRM_Meta();
public glTF_VRM_Humanoid humanoid = new glTF_VRM_Humanoid();
public glTF_VRM_Firstperson firstPerson = new glTF_VRM_Firstperson();
@ -47,6 +50,7 @@ VRM extension is for 3d humanoid avatars (and models) in VR applications.
protected override void SerializeMembers(GLTFJsonFormatter f)
{
f.KeyValue(() => exporterVersion);
f.KeyValue(() => schemaVersion);
f.Key("meta"); f.GLTFValue(meta);
f.Key("humanoid"); f.GLTFValue(humanoid);
f.Key("firstPerson"); f.GLTFValue(firstPerson);

View File

@ -0,0 +1,18 @@
using System;
namespace VRM
{
public class VRMSchemaVersion
{
public const int Major = 0;
public const int Minor = 0;
public static string Version
{
get
{
return String.Format("{0}.{1}", Major, Minor);
}
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3c5b8467d0154d6da78a74ecae5f85e7
timeCreated: 1549016543