public virtual void EnableAutoPoser(bool continuous) { // Check if AutoPoser was set if (autoPoser == null || !autoPoser.gameObject.activeInHierarchy) { if (handPoser != null) { autoPoser = handPoser.GetComponent <AutoPoser>(); } // Check for active children else { autoPoser = GetComponentInChildren <AutoPoser>(false); } } // Do the auto pose if (autoPoser != null) { autoPoser.UpdateContinuously = continuous; if (!continuous) { autoPoser.UpdateAutoPoseOnce(); } DisableHandAnimator(); } }
public void AutoAddFingerTipColliders(AutoPoser poser) { poser.ThumbCollider = GetOrAddTipCollider(poser.InspectedPose.GetThumbTip(), "tip_collider_t"); poser.IndexFingerCollider = GetOrAddTipCollider(poser.InspectedPose.GetIndexTip(), "tip_collider_i"); poser.MiddleFingerCollider = GetOrAddTipCollider(poser.InspectedPose.GetMiddleTip(), "tip_collider_m"); poser.RingFingerCollider = GetOrAddTipCollider(poser.InspectedPose.GetRingTip(), "tip_collider_r"); poser.PinkyFingerCollider = GetOrAddTipCollider(poser.InspectedPose.GetPinkyTip(), "tip_collider_p"); }
public override void OnInspectorGUI() { poser = (AutoPoser)target; serializedObject.Update(); GUILayout.Label("Auto Pose", EditorStyles.boldLabel); EditorGUILayout.PropertyField(openHandPose); EditorGUILayout.PropertyField(closedHandPose); EditorGUILayout.PropertyField(idleHandPose); EditorGUILayout.PropertyField(collisionLayerMask); EditorGUILayout.PropertyField(fingerTipRadius); showColliderOffsets = EditorGUILayout.Foldout(showColliderOffsets, "Finger Tip Offsets"); if (showColliderOffsets) { EditorGUILayout.HelpBox("You can manually adjust each fingertip's position / scale by specifying a FingerTipCollider object below. Press the 'Auto Add Tip Colliders' to create and populate the objects for you.", MessageType.Info); if (GUILayout.Button("Auto Setup Finger Tip Colliders")) { AutoAddFingerTipColliders(poser); } EditorGUILayout.PropertyField(thumbCollider); EditorGUILayout.PropertyField(indexFingerCollider); EditorGUILayout.PropertyField(middleFingerCollider); EditorGUILayout.PropertyField(ringFingerCollider); EditorGUILayout.PropertyField(pinkyFingerCollider); } EditorGUILayout.Separator(); EditorGUILayout.PropertyField(autoUpdateAutoPose); EditorGUILayout.Separator(); if (GUILayout.Button("Auto Pose")) { poser.UpdateAutoPose(false); } // GUILayout.Label("Editor Gizmos", EditorStyles.boldLabel); showGizmoProps = EditorGUILayout.Foldout(showGizmoProps, "Editor Gizmos"); if (showGizmoProps) { EditorGUILayout.PropertyField(showGizmos); EditorGUILayout.PropertyField(gizmoType); EditorGUILayout.PropertyField(gizmoColor); } serializedObject.ApplyModifiedProperties(); }
public void UpdateAutoPoserPreview() { if (handPoseType == HandPoseType.AutoPoseContinuous || handPoseType == HandPoseType.AutoPoseOnce) { Transform leftHandPreview = transform.Find("LeftHandModelsEditorPreview"); Transform rightHandPreview = transform.Find("RightHandModelsEditorPreview"); // Update in editor if (leftHandPreview) { AutoPoser ap = leftHandPreview.GetComponentInChildren <AutoPoser>(); if (ap != null) { ap.UpdateContinuously = true; } } if (rightHandPreview) { AutoPoser ap = rightHandPreview.GetComponentInChildren <AutoPoser>(); if (ap != null) { ap.UpdateContinuously = true; } } } else { Transform leftHandPreview = transform.Find("LeftHandModelsEditorPreview"); Transform rightHandPreview = transform.Find("RightHandModelsEditorPreview"); // Update in editor if (leftHandPreview) { AutoPoser ap = leftHandPreview.GetComponentInChildren <AutoPoser>(); if (ap != null) { ap.UpdateContinuously = false; } } if (rightHandPreview) { AutoPoser ap = rightHandPreview.GetComponentInChildren <AutoPoser>(); if (ap != null) { ap.UpdateContinuously = false; } } } }