From 5b815a874b94ded7485d178f190286d735e3d078 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Tue, 19 Apr 2022 15:36:26 +0900 Subject: [PATCH] =?UTF-8?q?joint=20=E3=81=8C=E8=A4=87=E6=95=B0=E3=81=AE=20?= =?UTF-8?q?chain=20=E3=81=AB=E6=89=80=E5=B1=9E=E3=81=99=E3=82=8B=E5=A0=B4?= =?UTF-8?q?=E5=90=88=E3=81=AB=20AddComponent=20=E3=81=AB=E5=A4=B1=E6=95=97?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/VRM10/Runtime/IO/Vrm10Importer.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs index 355b1fc47..fbb241a5b 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs @@ -615,7 +615,17 @@ namespace UniVRM10 // に基づきデフォルト値を補う // node is required - var joint = Nodes[gltfJoint.Node.Value].gameObject.AddComponent(); + var go = Nodes[gltfJoint.Node.Value].gameObject; + var joint = go.GetComponent(); + if (joint != null) + { + // 仕様違反。マイグレーションで発生しうるのと、エクスポーターでの除外などがされていないので、 + // エラーにせずに飛ばす + Debug.LogWarning($"duplicated spring joint: {Data.TargetPath}"); + continue; + } + + joint = go.AddComponent(); joint.m_jointRadius = gltfJoint.HitRadius.GetValueOrDefault(0.0f); joint.m_dragForce = gltfJoint.DragForce.GetValueOrDefault(0.5f); joint.m_gravityDir = gltfJoint.GravityDir != null ? Vector3InvertX(gltfJoint.GravityDir) : Vector3.down;