ViveInput.cs 936 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. if (teleport.GetStateDown(SteamVR_Input_Sources.Any))
  25. {
  26. playerReplay.Save();
  27. }
  28. if (grabGrib.GetStateDown(SteamVR_Input_Sources.Any))
  29. {
  30. playerReplay.Load();
  31. }
  32. }
  33. }