Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add specVersion field to VRM extensions #162

Merged
merged 2 commits into from
Feb 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<glTF_VRM_extensions>().Serialize(model, c);
Assert.AreEqual(@"{""exporterVersion"":""UniVRM-0.50"",""specVersion"":""0.0""}",json2);
}

// TODO: Move to another suitable location
T deserialize<T>(string json)
{
Expand Down
4 changes: 4 additions & 0 deletions Assets/VRM/UniVRM/Scripts/Format/VRMFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions Assets/VRM/UniVRM/Scripts/Format/VRMSpecVersion.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
}
3 changes: 3 additions & 0 deletions Assets/VRM/UniVRM/Scripts/Format/VRMSpecVersion.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.