diff --git a/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderDrawer.cs b/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderDrawer.cs new file mode 100644 index 000000000..72820c84e --- /dev/null +++ b/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderDrawer.cs @@ -0,0 +1,21 @@ +using UnityEditor; +using UnityEngine; + +namespace UniVRM10 +{ + [CustomPropertyDrawer(typeof(VRM10SpringBoneCollider))] + public class VRM10SpringBoneColliderDrawer : PropertyDrawer + { + public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label) + { + try + { + EditorGUI.ObjectField(rect, property, new GUIContent(((VRM10SpringBoneCollider)property.objectReferenceValue).GetIdentificationName())); + } + catch + { + EditorGUI.ObjectField(rect, property, new GUIContent()); + } + } + } +} \ No newline at end of file diff --git a/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderDrawer.cs.meta b/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderDrawer.cs.meta new file mode 100644 index 000000000..99083b751 --- /dev/null +++ b/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fe667808067766449993409eec01bed5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderEditor.cs b/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderEditor.cs index adb525d6a..c4b0ff4df 100644 --- a/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderEditor.cs +++ b/Assets/VRM10/Editor/Components/SpringBone/VRM10SpringBoneColliderEditor.cs @@ -13,7 +13,11 @@ namespace UniVRM10 GUI.backgroundColor = Color.cyan; Repaint(); } - base.OnInspectorGUI(); + var property = serializedObject.FindProperty("m_Script"); + var script = (VRM10SpringBoneCollider)target; + EditorGUILayout.PropertyField(property, new GUIContent("Script (" + script.GetIdentificationName() + ")")); + DrawPropertiesExcluding(serializedObject, "m_Script"); + serializedObject.ApplyModifiedProperties(); } } } diff --git a/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneCollider.cs b/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneCollider.cs index e0d257405..60e3c45de 100644 --- a/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneCollider.cs +++ b/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneCollider.cs @@ -45,5 +45,33 @@ namespace UniVRM10 break; } } + + public string GetIdentificationName() + { + var index = 0; + var count = 0; + + var colliders = transform.GetComponents(); + foreach (var collider in colliders) + { + if (collider.ColliderType == ColliderType) + { + count++; + } + if (collider == this) + { + index = count; + } + } + + if (count > 1) + { + return ColliderType.ToString() + index.ToString(); + } + else + { + return ColliderType.ToString(); + } + } } }