private void ToggleHand(PreviewHand hand) { Undo.RecordObject(hand.gameObject, "Toggle Hand"); bool isActive = !hand.gameObject.activeSelf; hand.gameObject.SetActive(isActive); }
public void Save(PreviewHand hand) { attachPosition = hand.transform.localPosition; attachRotation = hand.transform.localRotation; fingerRotations = hand.GetJointRotations(); }
public void Save(PreviewHand hand) { // Save position and rotation attachPosition = hand.transform.localPosition; attachRotation = hand.transform.localRotation; // Save rotations from the hand's current joints fingerRotations = hand.GetJointRotations(); }
public void MirrorAndApplyPose(PreviewHand sourceHand) { var mirroredRotations = MirrorJoints(sourceHand.Joints); ApplyFingerRotations(mirroredRotations); var mirroredPosition = MirrorPosition(sourceHand.transform); var mirroredRotation = MirrorRotation(sourceHand.transform); ApplyOffset(mirroredPosition, mirroredRotation); }
public void MirrorAndApplyPose(PreviewHand sourceHand) { // Mirror and apply the joint values List <Quaternion> mirroredRotations = MirrorJoints(sourceHand.Joints); ApplyFingerRotations(mirroredRotations); // Mirror and apply the position and rotation Vector3 mirroredPosition = MirrorPosition(sourceHand.transform); Quaternion mirroredRotation = MirrorRotation(sourceHand.transform); ApplyOffset(mirroredPosition, mirroredRotation); }
private void CreateHandPreviews() { LeftHand = CreateHand(leftHandPrefab); RightHand = CreateHand(rightHandPrefab); }
private void OnEnable() { previewHand = target as PreviewHand; }
private void CreateHandPreviews() { // Create both hands LeftHand = CreateHand(leftHandPrefab); RightHand = CreateHand(rightHandPrefab); }
private void OnGUI() { GUIStyle labelStyle = EditorStyles.label; labelStyle.alignment = TextAnchor.MiddleCenter; string poseName = activePose ? activePose.name : "No Pose"; GUILayout.Label(poseName, labelStyle); using (new EditorGUI.DisabledScope(activePose)) { if (GUILayout.Button("Create Pose")) { CreatePose(); } if (GUILayout.Button("Refresh Pose")) { RefreshPose(); } } using (new EditorGUI.DisabledScope(!activePose)) { if (GUILayout.Button("Clear Pose")) { ClearPose(); } } using (new EditorGUI.DisabledScope(!handManager.HandsExist)) { PreviewHand leftHand = handManager.LeftHand; PreviewHand rightHand = handManager.RightHand; float objectWidth = EditorGUIUtility.currentViewWidth * 0.5f; // Hand labels using (new GUILayout.HorizontalScope()) { GUILayout.Label("Left Hand", labelStyle, GUILayout.Width(objectWidth)); GUILayout.Label("Right Hand", labelStyle, GUILayout.Width(objectWidth)); } // Toggle buttons using (new GUILayout.HorizontalScope()) { if (GUILayout.Button("Toggle", GUILayout.Width(objectWidth))) { ToggleHand(leftHand); } if (GUILayout.Button("Toggle", GUILayout.Width(objectWidth))) { ToggleHand(rightHand); } } // Buttons that require a pose using (new EditorGUI.DisabledScope(!activePose)) { using (new GUILayout.HorizontalScope()) { if (GUILayout.Button("Mirror L > R", GUILayout.Width(objectWidth))) { MirrorPose(leftHand, rightHand); } if (GUILayout.Button("Mirror R > L", GUILayout.Width(objectWidth))) { MirrorPose(rightHand, leftHand); } } using (new GUILayout.HorizontalScope()) { if (GUILayout.Button("Undo Changes", GUILayout.Width(objectWidth))) { UndoChanges(leftHand); } if (GUILayout.Button("Undo Changes", GUILayout.Width(objectWidth))) { UndoChanges(rightHand); } } using (new GUILayout.HorizontalScope()) { if (GUILayout.Button("Reset", GUILayout.Width(objectWidth))) { ResetPose(leftHand); } if (GUILayout.Button("Reset", GUILayout.Width(objectWidth))) { ResetPose(rightHand); } } } } using (new EditorGUI.DisabledScope(!activePose)) { GUILayout.Label("Remember to Save!", labelStyle); if (GUILayout.Button("Save Pose")) { handManager.SavePose(activePose); } } }
private void MirrorPose(PreviewHand sourceHand, PreviewHand targetHand) { Undo.RecordObject(targetHand.transform, "Mirror Pose"); targetHand.MirrorAndApplyPose(sourceHand); }
private void UndoChanges(PreviewHand hand) { Undo.RecordObject(hand.transform, "Undo Changes"); hand.ApplyPose(activePose); }
private void ResetPose(PreviewHand hand) { Undo.RecordObject(hand.transform, "Reset Pose"); hand.ApplyDefaultPose(); }