From 646137b221ec8c63aa9f1d5fa174ecb0122e9a2e Mon Sep 17 00:00:00 2001 From: ousttrue Date: Tue, 27 Feb 2024 19:19:02 +0900 Subject: [PATCH 1/3] =?UTF-8?q?VRM10SpringBoneColliderGroup=20=E3=81=AE?= =?UTF-8?q?=E5=90=8D=E5=89=8D=E5=8F=8D=E6=98=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/VRM10/Runtime/IO/Vrm10Importer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs index 640e3afc5..e3a608e8b 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs @@ -554,6 +554,7 @@ namespace UniVRM10 foreach (var g in gltfVrmSpringBone.ColliderGroups) { var colliderGroup = secondary.gameObject.AddComponent(); + colliderGroup.Name = g.Name; controller.SpringBone.ColliderGroups.Add(colliderGroup); if (g != null && g.Colliders != null) From b0f75f7e26fc2284766b0b61b5b5b64ec66da48e Mon Sep 17 00:00:00 2001 From: ousttrue Date: Tue, 27 Feb 2024 19:19:42 +0900 Subject: [PATCH 2/3] =?UTF-8?q?migration=20=E6=99=82=E3=81=AB=20spring=20?= =?UTF-8?q?=E9=96=A2=E9=80=A3=E3=81=AE=E5=90=8D=E5=89=8D=E3=82=92=E4=BB=98?= =?UTF-8?q?=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Migration/MigrationVrmSpringBone.cs | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/Assets/VRM10/Runtime/Migration/MigrationVrmSpringBone.cs b/Assets/VRM10/Runtime/Migration/MigrationVrmSpringBone.cs index ff2f6400f..a298ed352 100644 --- a/Assets/VRM10/Runtime/Migration/MigrationVrmSpringBone.cs +++ b/Assets/VRM10/Runtime/Migration/MigrationVrmSpringBone.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using UniGLTF.Extensions.VRMC_springBone; using UniJSON; @@ -48,6 +49,23 @@ namespace UniVRM10 MigrateRootBone(vrm0Bone.GetInt32()); } } + + // fallback. default spring names + foreach (var spring in _springs) + { + if (string.IsNullOrEmpty(spring.Name) && spring.Joints.Count > 0 && spring.Joints[0].Node.HasValue) + { + var i = spring.Joints[0].Node.Value; + if (i >= 0 && i < _gltf.nodes.Count) + { + spring.Name = _gltf.nodes[i].name; + } + } + } + if (string.IsNullOrEmpty(_comment) && _springs.Count > 0) + { + _comment = _springs[0].Name; + } } Spring CreateSpring() @@ -263,6 +281,15 @@ namespace UniVRM10 { Colliders = colliderIndices.ToArray(), }; + if (colliderGroup.Colliders.Length > 0 && springBone.Colliders[colliderGroup.Colliders[0]].Node.HasValue) + { + var i = springBone.Colliders[colliderGroup.Colliders[0]].Node.Value; + if (i >= 0 && i < gltf.nodes.Count) + { + var node = gltf.nodes[i]; + colliderGroup.Name = node.name; + } + } springBone.ColliderGroups.Add(colliderGroup); } From 712b35c5427d470f94ead734ead1f448eb79744d Mon Sep 17 00:00:00 2001 From: ousttrue Date: Tue, 27 Feb 2024 19:20:11 +0900 Subject: [PATCH 3/3] =?UTF-8?q?inspector=20=E3=81=AE=20list=20=E3=81=A7=20?= =?UTF-8?q?VRM10SpringBoneColliderGroup=20=E3=81=AE=E5=90=8D=E5=89=8D?= =?UTF-8?q?=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VRM10SpringBoneColliderGroupDrawer.cs | 22 +++++++++++++++++++ ...VRM10SpringBoneColliderGroupDrawer.cs.meta | 11 ++++++++++ 2 files changed, 33 insertions(+) create mode 100644 Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneColliderGroupDrawer.cs create mode 100644 Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneColliderGroupDrawer.cs.meta diff --git a/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneColliderGroupDrawer.cs b/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneColliderGroupDrawer.cs new file mode 100644 index 000000000..3159fd8fd --- /dev/null +++ b/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneColliderGroupDrawer.cs @@ -0,0 +1,22 @@ + +using UnityEditor; +using UnityEngine; + +namespace UniVRM10 +{ + [CustomPropertyDrawer(typeof(VRM10SpringBoneColliderGroup))] + public class VRM10SpringBoneColliderGroupDrawer : PropertyDrawer + { + public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label) + { + try + { + EditorGUI.ObjectField(rect, property, new GUIContent(((VRM10SpringBoneColliderGroup)property.objectReferenceValue).Name)); + } + catch + { + EditorGUI.ObjectField(rect, property, new GUIContent("fallback")); + } + } + } +} \ No newline at end of file diff --git a/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneColliderGroupDrawer.cs.meta b/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneColliderGroupDrawer.cs.meta new file mode 100644 index 000000000..e144f3f0f --- /dev/null +++ b/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneColliderGroupDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9f5afdd3051fad24e9c7cb8caa29dc7f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: