ViveInput.cs 966 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. private SteamVR_Action_Boolean grabPinch;
  9. private SteamVR_Action_Boolean grabGrib;
  10. private SteamVR_Action_Boolean teleport;
  11. private void Start()
  12. {
  13. grabPinch = SteamVR_Actions.default_GrabPinch;
  14. grabGrib = SteamVR_Actions.default_GrabGrip;
  15. teleport = SteamVR_Actions.default_Teleport;
  16. }
  17. // Update is called once per frame
  18. void Update()
  19. {
  20. if (grabPinch.GetStateDown(SteamVR_Input_Sources.Any))
  21. {
  22. playerReplay.AddJoints();
  23. }
  24. // TODO: need to test
  25. if (teleport.GetStateDown(SteamVR_Input_Sources.Any))
  26. {
  27. playerReplay.Save();
  28. }
  29. if (grabGrib.GetStateDown(SteamVR_Input_Sources.Any))
  30. {
  31. playerReplay.Load();
  32. }
  33. }
  34. }