From 6c2da9704ae54dd9a7abf9367b6c1dc32cb596a1 Mon Sep 17 00:00:00 2001 From: yutopp Date: Fri, 1 Feb 2019 20:04:00 +0900 Subject: [PATCH 1/2] Add schemaVersion field to VRM extensions --- .../Editor/Tests/UniVRMSerializeTests.cs | 21 +++++++++++++++++++ Assets/VRM/UniVRM/Scripts/Format/VRMFormat.cs | 4 ++++ .../UniVRM/Scripts/Format/VRMSchemaVersion.cs | 18 ++++++++++++++++ .../Scripts/Format/VRMSchemaVersion.cs.meta | 3 +++ 4 files changed, 46 insertions(+) create mode 100644 Assets/VRM/UniVRM/Scripts/Format/VRMSchemaVersion.cs create mode 100644 Assets/VRM/UniVRM/Scripts/Format/VRMSchemaVersion.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs b/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs index b3d3362d9f..e74cc58467 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"",""schemaVersion"":""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..741be3ccaa 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 = @"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 @@ public static string ExtensionName 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); diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMSchemaVersion.cs b/Assets/VRM/UniVRM/Scripts/Format/VRMSchemaVersion.cs new file mode 100644 index 0000000000..fab0d2e228 --- /dev/null +++ b/Assets/VRM/UniVRM/Scripts/Format/VRMSchemaVersion.cs @@ -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); + } + } + } +} diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMSchemaVersion.cs.meta b/Assets/VRM/UniVRM/Scripts/Format/VRMSchemaVersion.cs.meta new file mode 100644 index 0000000000..7c160b301b --- /dev/null +++ b/Assets/VRM/UniVRM/Scripts/Format/VRMSchemaVersion.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3c5b8467d0154d6da78a74ecae5f85e7 +timeCreated: 1549016543 \ No newline at end of file From 48f8f602f54bf0a8450de6cdb93398eef2d37d00 Mon Sep 17 00:00:00 2001 From: yutopp Date: Fri, 1 Feb 2019 20:51:03 +0900 Subject: [PATCH 2/2] Rename schemaVersion to specVersion --- Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs | 2 +- Assets/VRM/UniVRM/Scripts/Format/VRMFormat.cs | 6 +++--- .../Format/{VRMSchemaVersion.cs => VRMSpecVersion.cs} | 2 +- .../{VRMSchemaVersion.cs.meta => VRMSpecVersion.cs.meta} | 0 4 files changed, 5 insertions(+), 5 deletions(-) rename Assets/VRM/UniVRM/Scripts/Format/{VRMSchemaVersion.cs => VRMSpecVersion.cs} (89%) rename Assets/VRM/UniVRM/Scripts/Format/{VRMSchemaVersion.cs.meta => VRMSpecVersion.cs.meta} (100%) diff --git a/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs b/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs index e74cc58467..8fba75208c 100644 --- a/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs +++ b/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs @@ -635,7 +635,7 @@ public void ExtensionsTest() EnableDiagnosisForNotRequiredFields = true, }; var json2 = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual(@"{""exporterVersion"":""UniVRM-0.50"",""schemaVersion"":""0.0""}",json2); + Assert.AreEqual(@"{""exporterVersion"":""UniVRM-0.50"",""specVersion"":""0.0""}",json2); } // TODO: Move to another suitable location diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMFormat.cs b/Assets/VRM/UniVRM/Scripts/Format/VRMFormat.cs index 741be3ccaa..501328e152 100644 --- a/Assets/VRM/UniVRM/Scripts/Format/VRMFormat.cs +++ b/Assets/VRM/UniVRM/Scripts/Format/VRMFormat.cs @@ -37,8 +37,8 @@ public static string ExtensionName [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; + [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(); @@ -50,7 +50,7 @@ public static string ExtensionName protected override void SerializeMembers(GLTFJsonFormatter f) { f.KeyValue(() => exporterVersion); - f.KeyValue(() => schemaVersion); + 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/VRMSchemaVersion.cs b/Assets/VRM/UniVRM/Scripts/Format/VRMSpecVersion.cs similarity index 89% rename from Assets/VRM/UniVRM/Scripts/Format/VRMSchemaVersion.cs rename to Assets/VRM/UniVRM/Scripts/Format/VRMSpecVersion.cs index fab0d2e228..98ece65e76 100644 --- a/Assets/VRM/UniVRM/Scripts/Format/VRMSchemaVersion.cs +++ b/Assets/VRM/UniVRM/Scripts/Format/VRMSpecVersion.cs @@ -2,7 +2,7 @@ namespace VRM { - public class VRMSchemaVersion + public class VRMSpecVersion { public const int Major = 0; public const int Minor = 0; diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMSchemaVersion.cs.meta b/Assets/VRM/UniVRM/Scripts/Format/VRMSpecVersion.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/VRMSchemaVersion.cs.meta rename to Assets/VRM/UniVRM/Scripts/Format/VRMSpecVersion.cs.meta