HandTrackingExample.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections;
  3. using UnityEngine;
  4. namespace NRKernal.NRExamples
  5. {
  6. public class HandTrackingExample : MonoBehaviour
  7. {
  8. public ItemsCollector itemsCollector;
  9. public HandModelsManager handModelsManager;
  10. public void StartHandTracking()
  11. {
  12. Debug.Log("HandTrackingExample: StartHandTracking");
  13. NRInput.SetInputSource(InputSourceEnum.Hands);
  14. }
  15. public void StopHandTracking()
  16. {
  17. Debug.Log("HandTrackingExample: StopHandTracking");
  18. NRInput.SetInputSource(InputSourceEnum.Controller);
  19. }
  20. public void ToggleRaycastMode()
  21. {
  22. Debug.Log("HandTrackingExample: ToggleRaycastMode");
  23. NRInput.RaycastMode = NRInput.RaycastMode == RaycastModeEnum.Gaze ? RaycastModeEnum.Laser : RaycastModeEnum.Gaze;
  24. }
  25. public void HideRayFor5Seconds()
  26. {
  27. Debug.Log("HandTrackingExample: HideRayFor5Seconds");
  28. CancelInvoke("ShowRay");
  29. NRInput.RaycastersActive = false;
  30. Invoke("ShowRay", 5f);
  31. }
  32. public void SwitchHandVisual()
  33. {
  34. Debug.Log("HandTrackingExample: SwitchHandVisual");
  35. handModelsManager.ToggleHandModelsGroup();
  36. }
  37. public void ResetItems()
  38. {
  39. Debug.LogWarning("HandTrackingExample: ResetItems");
  40. itemsCollector.ResetItems();
  41. }
  42. private void ShowRay()
  43. {
  44. NRInput.RaycastersActive = true;
  45. }
  46. }
  47. }