AttributeRegulation.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using Rokid.UXR.Interaction;
  4. using Rokid.UXR.Native;
  5. namespace Rokid.UXR.Demo
  6. {
  7. public class AttributeRegulation : AutoInjectBehaviour
  8. {
  9. [SerializeField, Autowrited]
  10. private PokeInteractable[] interactables;
  11. [SerializeField, Autowrited]
  12. private Text hoverTip;
  13. [SerializeField, Autowrited]
  14. private Text palmTip;
  15. [SerializeField, Autowrited]
  16. private Toggle fishEyeToggle;
  17. [SerializeField, Autowrited]
  18. private Toggle dspCloseAll;
  19. [SerializeField, Autowrited]
  20. private Toggle dspOnlyDetection;
  21. [SerializeField, Autowrited]
  22. private Toggle dspOnlyFollow;
  23. [SerializeField, Autowrited]
  24. private Toggle dspOpenAll;
  25. [SerializeField, Autowrited]
  26. private Toggle logToggle;
  27. [SerializeField, Autowrited]
  28. private Slider userHeightSlider;
  29. [SerializeField, Autowrited]
  30. private Text userHeightText;
  31. [SerializeField, Autowrited]
  32. private Toggle headHandToggle;
  33. private void Start()
  34. {
  35. interactables = GameObject.FindObjectsOfType<PokeInteractable>();
  36. fishEyeToggle?.onValueChanged.AddListener(isOn =>
  37. {
  38. SetUseFishEyeDistort(isOn ? 1 : 0);
  39. });
  40. dspCloseAll?.onValueChanged.AddListener(isOn =>
  41. {
  42. if (isOn)
  43. {
  44. SetUseDsp(0);
  45. }
  46. });
  47. dspOnlyDetection?.onValueChanged.AddListener(isOn =>
  48. {
  49. if (isOn)
  50. {
  51. SetUseDsp(1);
  52. }
  53. });
  54. dspOnlyFollow?.onValueChanged.AddListener(isOn =>
  55. {
  56. if (isOn)
  57. {
  58. SetUseDsp(2);
  59. }
  60. });
  61. dspOpenAll?.onValueChanged.AddListener(isOn =>
  62. {
  63. if (isOn)
  64. {
  65. SetUseDsp(3);
  66. }
  67. });
  68. logToggle?.onValueChanged.AddListener(isOn =>
  69. {
  70. Debug.unityLogger.logEnabled = isOn;
  71. });
  72. if (dspOnlyDetection != null)
  73. {
  74. dspOnlyDetection.isOn = true;
  75. }
  76. userHeightSlider.value = 170.0f / 200;
  77. userHeightText.text = $"User Height :{(int)(userHeightSlider.value * 200)}";
  78. userHeightSlider.onValueChanged.AddListener(value =>
  79. {
  80. userHeightText.text = $"User Height :{(int)(userHeightSlider.value * 200)}";
  81. GesEventInput.Instance.SetUserHeight((int)(userHeightSlider.value * 200));
  82. });
  83. headHandToggle.onValueChanged.AddListener(value =>
  84. {
  85. if (value)
  86. {
  87. GesEventInput.Instance.ActiveHandOrHeadHand(HandOrHeadHandType.HeadHand);
  88. }
  89. else
  90. {
  91. GesEventInput.Instance.ActiveHandOrHeadHand(HandOrHeadHandType.NormalHand);
  92. }
  93. });
  94. }
  95. /// <summary>
  96. /// 是否使用鱼眼校正,0-否,1-是
  97. /// </summary>
  98. public void SetUseFishEyeDistort(int useFishEyeDistort)
  99. {
  100. NativeInterface.NativeAPI.SetUseFishEyeDistort(useFishEyeDistort);
  101. }
  102. /// <summary>
  103. /// 0 是 检测 和 跟踪都不开 dsp
  104. /// 1 是 检测开 跟踪不开
  105. /// 2 是 检测不开 跟踪开
  106. /// 3 是 都开
  107. /// </summary>
  108. public void SetUseDsp(int useDsp)
  109. {
  110. RKLog.KeyInfo("SetUseDsp:" + useDsp);
  111. NativeInterface.NativeAPI.SetUseDsp(useDsp);
  112. }
  113. }
  114. }