public FingerTipCollider GetOrAddTipCollider(Transform tipTransform, string tipName) { if (tipTransform != null) { // Check for existing and return that if available FingerTipCollider col = tipTransform.GetComponentInChildren <FingerTipCollider>(); if (col != null) { return(col); } // Otherwise create a new one and parent it to the tip of the finger GameObject tipCollider = new GameObject(tipName); col = tipCollider.AddComponent <FingerTipCollider>(); tipCollider.transform.parent = tipTransform; tipCollider.transform.localPosition = Vector3.zero; tipCollider.transform.localEulerAngles = Vector3.zero; tipCollider.transform.localScale = Vector3.one; return(col); } return(null); }
public void DrawJointGizmo(FingerTipCollider tipCollider, Vector3 defaultPosition, float radius, GizmoDisplayType gizmoType) { if (tipCollider != null) { defaultPosition = tipCollider.transform.position; radius = tipCollider.Radius; } if (gizmoType == GizmoDisplayType.Wire) { Gizmos.DrawWireSphere(defaultPosition, radius); } else if (GizmoType == GizmoDisplayType.Solid) { Gizmos.DrawSphere(defaultPosition, radius); } }