HandTrackingChecker.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // /******************************************************************************
  2. // * File: HandTrackingChecker.cs
  3. // * Copyright (c) 2023 Qualcomm Technologies, Inc. and/or its subsidiaries. All rights reserved.
  4. // *
  5. // *
  6. // ******************************************************************************/
  7. using System.Collections;
  8. using QCHT.Interactions.Core;
  9. using QCHT.Samples.Menu;
  10. using UnityEngine;
  11. namespace QCHT.Samples.Menu
  12. {
  13. public class HandTrackingChecker : MonoBehaviour
  14. {
  15. [SerializeField] private XRHandTrackingManager manager;
  16. [SerializeField] private SampleSceneManager sampleSceneManager;
  17. [SerializeField] private GameObject warningToast;
  18. [SerializeField] private float idleDuration;
  19. private float _handTrackingIdleTime;
  20. private void Start()
  21. {
  22. // warningToast.SetActive(false);
  23. }
  24. private void Update()
  25. {
  26. if (manager.HandTrackingStatus == XRHandTrackingSubsystem.QchtStatus.QchtStatusRunning)
  27. {
  28. _handTrackingIdleTime = 0;
  29. return;
  30. }
  31. _handTrackingIdleTime += Time.deltaTime;
  32. if (_handTrackingIdleTime > idleDuration)
  33. {
  34. _handTrackingIdleTime = 0;
  35. StartCoroutine(CloseHandTrackingScene());
  36. }
  37. }
  38. IEnumerator CloseHandTrackingScene()
  39. {
  40. // warningToast.SetActive(true);
  41. yield return new WaitForSeconds(4f);
  42. // sampleSceneManager.SwitchToScene("Main Menu");
  43. }
  44. }
  45. }