ViveInput.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. }
  47. }