From f6babc46e032f3175a5d9a1b15d34adaacb1d820 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 27 Jan 2021 16:27:24 +0900 Subject: [PATCH] fix ApiSampleTests.cs --- .../Format/ExtensionsAndExtras/gltfExtension.cs | 2 +- Assets/VRM10/Runtime/IO/Vrm10Storage.cs | 2 +- Assets/VRM10/Runtime/IO/VrmSpringBoneAdapter.cs | 11 +++++++++-- .../Tests.PlayMode/VRM10.Tests.PlayMode.asmdef | 6 ++---- .../{Tests.PlayMode => Tests}/ApiSampleTests.cs | 13 ++++++------- .../ApiSampleTests.cs.meta | 0 6 files changed, 19 insertions(+), 15 deletions(-) rename Assets/VRM10/{Tests.PlayMode => Tests}/ApiSampleTests.cs (87%) rename Assets/VRM10/{Tests.PlayMode => Tests}/ApiSampleTests.cs.meta (100%) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/gltfExtension.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/gltfExtension.cs index 29e68f014..c7c458807 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/gltfExtension.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/gltfExtension.cs @@ -59,7 +59,7 @@ namespace UniGLTF public glTFExtensionExport Add(string key, ArraySegment raw) { - m_serialized.Add(key, raw); + m_serialized[key] = raw; return this; } diff --git a/Assets/VRM10/Runtime/IO/Vrm10Storage.cs b/Assets/VRM10/Runtime/IO/Vrm10Storage.cs index 20e452ef4..29b97b5f2 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Storage.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Storage.cs @@ -728,7 +728,7 @@ namespace UniVRM10 joint.GravityDir = gltfJoint.GravityDir.ToVector3(); joint.GravityPower = gltfJoint.GravityPower.Value; joint.Stiffness = gltfJoint.Stiffness.Value; - joint.Exclude = gltfJoint.Exclude.Value; + joint.Exclude = gltfJoint.Exclude.GetValueOrDefault(); springBone.Joints.Add(joint); } diff --git a/Assets/VRM10/Runtime/IO/VrmSpringBoneAdapter.cs b/Assets/VRM10/Runtime/IO/VrmSpringBoneAdapter.cs index 87d417835..3783ee201 100644 --- a/Assets/VRM10/Runtime/IO/VrmSpringBoneAdapter.cs +++ b/Assets/VRM10/Runtime/IO/VrmSpringBoneAdapter.cs @@ -18,7 +18,10 @@ namespace UniVRM10 return null; } - var springBone = new VRMC_springBone(); + var springBone = new VRMC_springBone + { + Springs = new List(), + }; // // VRMC_node_collider @@ -26,7 +29,10 @@ namespace UniVRM10 foreach (var nodeCollider in self.Springs.SelectMany(x => x.Colliders)) { var index = nodes.IndexOfThrow(nodeCollider.Node); - var gltfCollider = new VRMC_node_collider(); + var gltfCollider = new VRMC_node_collider + { + Shapes = new List(), + }; foreach (var y in nodeCollider.Colliders) { switch (y.ColliderType) @@ -80,6 +86,7 @@ namespace UniVRM10 { Name = x.Comment, Colliders = x.Colliders.Select(y => nodes.IndexOfThrow(y.Node)).ToArray(), + Joints = new List(), }; foreach (var y in x.Joints) diff --git a/Assets/VRM10/Tests.PlayMode/VRM10.Tests.PlayMode.asmdef b/Assets/VRM10/Tests.PlayMode/VRM10.Tests.PlayMode.asmdef index 180062d21..972ea0c0c 100644 --- a/Assets/VRM10/Tests.PlayMode/VRM10.Tests.PlayMode.asmdef +++ b/Assets/VRM10/Tests.PlayMode/VRM10.Tests.PlayMode.asmdef @@ -11,10 +11,8 @@ "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false, - "overrideReferences": true, + "overrideReferences": false, "precompiledReferences": [], "autoReferenced": false, - "defineConstraints": [ - "UNITY_INCLUDE_TESTS" - ] + "defineConstraints": [] } \ No newline at end of file diff --git a/Assets/VRM10/Tests.PlayMode/ApiSampleTests.cs b/Assets/VRM10/Tests/ApiSampleTests.cs similarity index 87% rename from Assets/VRM10/Tests.PlayMode/ApiSampleTests.cs rename to Assets/VRM10/Tests/ApiSampleTests.cs index c497474bd..17a7249f3 100644 --- a/Assets/VRM10/Tests.PlayMode/ApiSampleTests.cs +++ b/Assets/VRM10/Tests/ApiSampleTests.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; @@ -9,7 +10,7 @@ namespace UniVRM10.Test { VrmLib.Model ReadModel(string path) { - var bytes = File.ReadAllBytes(path); + var bytes = Migration.Migrate(File.ReadAllBytes(path)); if (!UniGLTF.Glb.TryParse(bytes, out UniGLTF.Glb glb, out Exception ex)) { @@ -17,7 +18,7 @@ namespace UniVRM10.Test return null; } - var model = UniVRM10.VrmLoader.CreateVrmModel(path); + var model = UniVRM10.VrmLoader.CreateVrmModel(bytes, new FileInfo(path)); return model; } @@ -43,10 +44,10 @@ namespace UniVRM10.Test return bytes; } - [UnityTest] - public bool Sample() + [Test] + public void Sample() { - var path = "Tests/Models/Alicia_vrm-1.00/AliciaSolid_vrm-1.00.vrm"; + var path = "Tests/Models/Alicia_vrm-0.51/AliciaSolid_vrm-0.51.vrm"; Debug.Log($"load: {path}"); // import @@ -74,8 +75,6 @@ namespace UniVRM10.Test var vrmBytes = ToVrm10(dstModel); Debug.Log($"export {vrmBytes.Length} bytes"); - - return true; } } } diff --git a/Assets/VRM10/Tests.PlayMode/ApiSampleTests.cs.meta b/Assets/VRM10/Tests/ApiSampleTests.cs.meta similarity index 100% rename from Assets/VRM10/Tests.PlayMode/ApiSampleTests.cs.meta rename to Assets/VRM10/Tests/ApiSampleTests.cs.meta