From ac5662f61fda4fd96fb8ead2fccd163f6a4f873c Mon Sep 17 00:00:00 2001 From: ousttrue Date: Tue, 13 Apr 2021 20:42:56 +0900 Subject: [PATCH] =?UTF-8?q?collider=E3=81=AE=E9=87=8D=E8=A4=87=E8=80=83?= =?UTF-8?q?=E6=85=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VRM10/Runtime/IO/RuntimeUnityBuilder.cs | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/Assets/VRM10/Runtime/IO/RuntimeUnityBuilder.cs b/Assets/VRM10/Runtime/IO/RuntimeUnityBuilder.cs index 0b63716f2..ac60d6783 100644 --- a/Assets/VRM10/Runtime/IO/RuntimeUnityBuilder.cs +++ b/Assets/VRM10/Runtime/IO/RuntimeUnityBuilder.cs @@ -384,33 +384,37 @@ namespace UniVRM10 out UniGLTF.Extensions.VRMC_node_collider.VRMC_node_collider extension)) { var node = Nodes[colliderNode]; - var colliderGroup = node.gameObject.GetOrAddComponent(); - colliderGroup.Colliders.AddRange(extension.Shapes.Select(x => + var colliderGroup = node.gameObject.GetComponent(); + if (colliderGroup == null) { - if (x.Sphere != null) + colliderGroup = node.gameObject.AddComponent(); + colliderGroup.Colliders.AddRange(extension.Shapes.Select(x => { - return new VRM10SpringBoneCollider + if (x.Sphere != null) { - ColliderType = VRM10SpringBoneColliderTypes.Sphere, - Offset = Vector3(x.Sphere.Offset), - Radius = x.Sphere.Radius.Value, - }; - } - else if (x.Capsule != null) - { - return new VRM10SpringBoneCollider + return new VRM10SpringBoneCollider + { + ColliderType = VRM10SpringBoneColliderTypes.Sphere, + Offset = Vector3(x.Sphere.Offset), + Radius = x.Sphere.Radius.Value, + }; + } + else if (x.Capsule != null) { - ColliderType = VRM10SpringBoneColliderTypes.Capsule, - Offset = Vector3(x.Capsule.Offset), - Radius = x.Capsule.Radius.Value, - Tail = Vector3(x.Capsule.Tail), - }; - } - else - { - throw new NotImplementedException(); - } - })); + return new VRM10SpringBoneCollider + { + ColliderType = VRM10SpringBoneColliderTypes.Capsule, + Offset = Vector3(x.Capsule.Offset), + Radius = x.Capsule.Radius.Value, + Tail = Vector3(x.Capsule.Tail), + }; + } + else + { + throw new NotImplementedException(); + } + })); + } return colliderGroup; } else