void OnEnable() { controller = (HandAnimationController)target; if (controller.HandData && !controller.Initialized) { controller.Init(); } EditorApplication.update += Update; }
public static void DisplayHandEditor(HandAnimationController controller, SerializedObject serializedObject) { if (controller.HandData && !controller.Initialized) { controller.Init(); } var fingers = serializedObject.FindProperty("fingers"); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(serializedObject.FindProperty("handData")); serializedObject.ApplyModifiedProperties(); if (EditorGUI.EndChangeCheck()) { controller.Init(); } EditorGUI.BeginChangeCheck(); controller.StaticPose = EditorGUILayout.Toggle(new GUIContent("static Pose"), controller.StaticPose); if (EditorGUI.EndChangeCheck()) { Undo.RegisterFullObjectHierarchyUndo(controller, "Changed static pose"); } if (controller.StaticPose) { var currentPose = serializedObject.FindProperty("pose"); var poses = serializedObject.FindProperty("poses"); string[] list = new string[poses.arraySize]; for (int i = 0; i < list.Length; i++) { list[i] = ((AnimationClip)poses.GetArrayElementAtIndex(i).FindPropertyRelative("clip").objectReferenceValue).name; } controller.Pose = EditorGUILayout.Popup(new GUIContent("pose"), currentPose.intValue, list); } else { for (int i = 0; i < fingers.arraySize; i++) { var fingerWeight = fingers.GetArrayElementAtIndex(i).FindPropertyRelative("weight"); EditorGUILayout.PropertyField(fingerWeight, new GUIContent(((FingerName)i).ToString())); } serializedObject.ApplyModifiedProperties(); for (int i = 0; i < 5; i++) { controller[i] = controller[i]; } } }
private void Start() { animationController = GetComponent <HandAnimationController>(); hand = GetComponent <Hand>(); switch (hand.hand) { case HandType.right: device = InputDevices.GetDeviceAtXRNode(XRNode.RightHand); break; case HandType.left: device = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand); break; default: break; } }
private void HandPositionSceneEditor(HandtoEdit hand) { if (visibleHand == null) { switch (hand) { case HandtoEdit.none: break; case HandtoEdit.right: visibleHand = GameObject.Instantiate <HandAnimationController>(interactable.handData.rightHandPrefab); break; case HandtoEdit.left: visibleHand = GameObject.Instantiate <HandAnimationController>(interactable.handData.leftHandPrefab); break; default: break; } } visibleHand.transform.parent = interactable.transform; switch (hand) { case HandtoEdit.none: break; case HandtoEdit.right: visibleHand.transform.localPosition = interactable.rightHandPivot.position; visibleHand.transform.localRotation = Quaternion.Euler(interactable.rightHandPivot.rotation); break; case HandtoEdit.left: visibleHand.transform.localPosition = interactable.leftHandPivot.position; visibleHand.transform.localRotation = Quaternion.Euler(interactable.leftHandPivot.rotation); break; default: break; } }
private void OnEnable() { Tools.hidden = false; interactable = (Interactable)target; EditorApplication.update += Update; if (visibleHand) { GameObject.DestroyImmediate(visibleHand.gameObject); HandtoEdit currentHand = HandtoEdit.none; } else if (visibleHand = interactable.GetComponentInChildren <HandAnimationController>()) { GameObject.DestroyImmediate(visibleHand.gameObject); visibleHand = null; } if (!interactable.handData) { interactable.handData = GameObject.FindObjectOfType <HandAnimationController>().HandData; } }
private void Start() { type = GetComponent <HandTracker>().type; collider = new Collider[1]; animationController = GetComponentInChildren <HandAnimationController>(); }