positionModify.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using SC.InputSystem;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class positionModify : MonoBehaviour {
  6. public InputDevicePartType partType;
  7. Vector3 offset = new Vector3(0f, 0f, 0f);
  8. float fv = 0.01f;//每次调节1cm
  9. void Start() {
  10. StartCoroutine(CheckGesture26Dof());
  11. }
  12. IEnumerator CheckGesture26Dof() {
  13. while(true) {
  14. yield return null;
  15. yield return new WaitUntil(() => InputSystem.Instant.Gesture26Dof == true);
  16. ///调节手的位置
  17. foreach(var part in InputSystem.Instant.Gesture26Dof.InputDevice26DofGesturePartList) {
  18. if(part.PartType == partType) {
  19. part.HandPositionModify(offset);
  20. }
  21. }
  22. }
  23. }
  24. public void Up() {
  25. offset += Vector3.up * fv;
  26. }
  27. public void Down() {
  28. offset += Vector3.down * fv;
  29. }
  30. public void Left() {
  31. offset += Vector3.left * fv;
  32. }
  33. public void Right() {
  34. offset += Vector3.right * fv;
  35. }
  36. public void Forward() {
  37. offset += Vector3.forward * fv;
  38. }
  39. public void Back() {
  40. offset += Vector3.back * fv;
  41. }
  42. void Update() {
  43. ///获取手掌中心位置
  44. //Debug.Log("HandCenterPosition:" + InputSystem.Instant.Gesture26Dof.InputDevice26DofGesturePartList[0].inputDevice26DofGestureUI.model26DofGesture.center.transform.position);
  45. ///获取关节点的位置
  46. //Debug.Log(InputSystem.Instant.Gesture26Dof.InputDevice26DofGesturePartList[0].GetJointPosition(true, SC.InputSystem.InputDevice26DofGesture.FINGER.forefinger, SC.InputSystem.InputDevice26DofGesture.JOINT.One));
  47. }
  48. }