VRMSpringBoneColliderGroup.cs
1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using UnityEngine;
namespace VRM
{
#if UNITY_5_5_OR_NEWER
[DefaultExecutionOrder(11001)]
#endif
public class VRMSpringBoneColliderGroup : MonoBehaviour
{
[Serializable]
public class SphereCollider
{
public Vector3 Offset;
[Range(0, 1.0f)]
public float Radius;
}
[SerializeField]
public SphereCollider[] Colliders = new SphereCollider[]{
new SphereCollider
{
Radius=0.1f
}
};
[SerializeField]
Color m_gizmoColor = Color.magenta;
private void OnDrawGizmosSelected()
{
Gizmos.color = m_gizmoColor;
Matrix4x4 mat = transform.localToWorldMatrix;
Gizmos.matrix = mat * Matrix4x4.Scale(new Vector3(
1.0f / transform.lossyScale.x,
1.0f / transform.lossyScale.y,
1.0f / transform.lossyScale.z
));
foreach (var y in Colliders)
{
Gizmos.DrawWireSphere(y.Offset, y.Radius);
}
}
}
}