diff --git a/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs b/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs index b3d3362d9f..8fba75208c 100644 --- a/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs +++ b/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs @@ -617,6 +617,27 @@ public void SecondaryAnimationTest() 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().Serialize(model, c); + Assert.AreEqual(@"{""exporterVersion"":""UniVRM-0.50"",""specVersion"":""0.0""}",json2); + } + // TODO: Move to another suitable location T deserialize(string json) { diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMFormat.cs b/Assets/VRM/UniVRM/Scripts/Format/VRMFormat.cs index 348c37b5b3..501328e152 100644 --- a/Assets/VRM/UniVRM/Scripts/Format/VRMFormat.cs +++ b/Assets/VRM/UniVRM/Scripts/Format/VRMFormat.cs @@ -37,6 +37,9 @@ public static string ExtensionName [JsonSchema(Description = @"Version of exporter that vrm created. " + VRMVersion.VRM_VERSION)] public string exporterVersion = "UniVRM-" + VRMVersion.VERSION; + [JsonSchema(Description = @"The VRM specification version that this extension uses")] + public string specVersion = VRMSpecVersion.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 @@ public static string ExtensionName protected override void SerializeMembers(GLTFJsonFormatter f) { f.KeyValue(() => exporterVersion); + f.KeyValue(() => specVersion); f.Key("meta"); f.GLTFValue(meta); f.Key("humanoid"); f.GLTFValue(humanoid); f.Key("firstPerson"); f.GLTFValue(firstPerson); diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMSpecVersion.cs b/Assets/VRM/UniVRM/Scripts/Format/VRMSpecVersion.cs new file mode 100644 index 0000000000..98ece65e76 --- /dev/null +++ b/Assets/VRM/UniVRM/Scripts/Format/VRMSpecVersion.cs @@ -0,0 +1,18 @@ +using System; + +namespace VRM +{ + public class VRMSpecVersion + { + public const int Major = 0; + public const int Minor = 0; + + public static string Version + { + get + { + return String.Format("{0}.{1}", Major, Minor); + } + } + } +} diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMSpecVersion.cs.meta b/Assets/VRM/UniVRM/Scripts/Format/VRMSpecVersion.cs.meta new file mode 100644 index 0000000000..7c160b301b --- /dev/null +++ b/Assets/VRM/UniVRM/Scripts/Format/VRMSpecVersion.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3c5b8467d0154d6da78a74ecae5f85e7 +timeCreated: 1549016543 \ No newline at end of file