From 20d068e16f14adc1863c5a2eaf08b73d39e0fcf6 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Tue, 22 Jun 2021 14:06:41 +0900 Subject: [PATCH] skip T if [0, 0, 0] --- .../Editor/UniGLTF/Serialization/SerializerGenerator.cs | 3 ++- Assets/UniGLTF/Runtime/UniGLTF/Format/GltfSerializer.g.cs | 3 ++- Assets/UniGLTF/Runtime/UniGLTF/Format/glTFNode.cs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Assets/UniGLTF/Editor/UniGLTF/Serialization/SerializerGenerator.cs b/Assets/UniGLTF/Editor/UniGLTF/Serialization/SerializerGenerator.cs index 3366b4897..232d7fb77 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/Serialization/SerializerGenerator.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization/SerializerGenerator.cs @@ -16,6 +16,7 @@ namespace UniGLTF const string Begin = @"using System; using System.Collections.Generic; using UniJSON; +using System.Linq; namespace UniGLTF { @@ -34,7 +35,7 @@ namespace UniGLTF { get { return Path.Combine(UnityEngine.Application.dataPath, - "UniGLTF/UniGLTF/Scripts/IO/GltfSerializer.g.cs"); + "UniGLTF/Runtime/UniGLTF/Format/GltfSerializer.g.cs"); } } diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/GltfSerializer.g.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/GltfSerializer.g.cs index 313d10bd0..c695f91f8 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/Format/GltfSerializer.g.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/GltfSerializer.g.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using UniJSON; +using System.Linq; namespace UniGLTF { @@ -1121,7 +1122,7 @@ public static void Serialize_gltf_nodes_ITEM(JsonFormatter f, glTFNode value) Serialize_gltf_nodes__matrix(f, value.matrix); } - if(value.translation!=null&&value.translation.Length>=3){ + if(value.translation!=null&&value.translation.Length>=3&&!value.translation.SequenceEqual(new float[]{0, 0, 0})){ f.Key("translation"); Serialize_gltf_nodes__translation(f, value.translation); } diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFNode.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFNode.cs index 955442d01..9d5bec958 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFNode.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFNode.cs @@ -17,7 +17,7 @@ namespace UniGLTF [JsonSchema(MinItems = 16, MaxItems = 16)] public float[] matrix; - [JsonSchema(MinItems = 3, MaxItems = 3)] + [JsonSchema(MinItems = 3, MaxItems = 3, SerializationConditions = new string[] { "!value.translation.SequenceEqual(new float[]{0, 0, 0})" })] public float[] translation; [JsonSchema(MinItems = 4, MaxItems = 4)]