ViveInput.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Valve.VR;
  5. public class ViveInput : MonoBehaviour
  6. {
  7. public PlayerReplay playerReplay;
  8. public BodySourceView bsv;
  9. private SteamVR_Action_Boolean grabPinch;
  10. private SteamVR_Action_Boolean grabGrib;
  11. private SteamVR_Action_Boolean teleport;
  12. //private SteamVR_Action_Vector2 trackpad;
  13. private bool isRecording;
  14. private float recordingTime;
  15. private void Start()
  16. {
  17. grabPinch = SteamVR_Actions.default_GrabPinch;
  18. grabGrib = SteamVR_Actions.default_GrabGrip;
  19. teleport = SteamVR_Actions.default_Teleport;
  20. }
  21. void Update()
  22. {
  23. if (grabPinch.GetStateDown(SteamVR_Input_Sources.Any))
  24. {
  25. Debug.Log("Recording...");
  26. isRecording = true;
  27. }
  28. if (teleport.GetStateDown(SteamVR_Input_Sources.Any))
  29. {
  30. Debug.Log("Saving...");
  31. isRecording = false;
  32. recordingTime = 0;
  33. playerReplay.Save();
  34. playerReplay.ResetRecording();
  35. }
  36. if (grabGrib.GetStateDown(SteamVR_Input_Sources.Any))
  37. {
  38. Debug.Log("Loading...");
  39. playerReplay.Load();
  40. }
  41. if (isRecording)
  42. {
  43. playerReplay.AddJoints(recordingTime);
  44. recordingTime += Time.deltaTime;
  45. }
  46. if (Input.GetKeyDown("up"))
  47. {
  48. Debug.Log("up");
  49. bsv.scale += 0.1f;
  50. }
  51. if (Input.GetKeyDown("down"))
  52. {
  53. Debug.Log("down");
  54. bsv.scale -= 0.1f;
  55. }
  56. }
  57. }