123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- using UnityEngine;
- using UnityEngine.UI;
- using Rokid.UXR.Interaction;
- using Rokid.UXR.Native;
- namespace Rokid.UXR.Demo
- {
- public class AttributeRegulation : AutoInjectBehaviour
- {
- [SerializeField, Autowrited]
- private PokeInteractable[] interactables;
- [SerializeField, Autowrited]
- private Text hoverTip;
- [SerializeField, Autowrited]
- private Text palmTip;
- [SerializeField, Autowrited]
- private Toggle fishEyeToggle;
- [SerializeField, Autowrited]
- private Toggle dspCloseAll;
- [SerializeField, Autowrited]
- private Toggle dspOnlyDetection;
- [SerializeField, Autowrited]
- private Toggle dspOnlyFollow;
- [SerializeField, Autowrited]
- private Toggle dspOpenAll;
- [SerializeField, Autowrited]
- private Toggle logToggle;
- [SerializeField, Autowrited]
- private Slider userHeightSlider;
- [SerializeField, Autowrited]
- private Text userHeightText;
- [SerializeField, Autowrited]
- private Toggle headHandToggle;
- private void Start()
- {
- interactables = GameObject.FindObjectsOfType<PokeInteractable>();
- fishEyeToggle?.onValueChanged.AddListener(isOn =>
- {
- SetUseFishEyeDistort(isOn ? 1 : 0);
- });
- dspCloseAll?.onValueChanged.AddListener(isOn =>
- {
- if (isOn)
- {
- SetUseDsp(0);
- }
- });
- dspOnlyDetection?.onValueChanged.AddListener(isOn =>
- {
- if (isOn)
- {
- SetUseDsp(1);
- }
- });
- dspOnlyFollow?.onValueChanged.AddListener(isOn =>
- {
- if (isOn)
- {
- SetUseDsp(2);
- }
- });
- dspOpenAll?.onValueChanged.AddListener(isOn =>
- {
- if (isOn)
- {
- SetUseDsp(3);
- }
- });
- logToggle?.onValueChanged.AddListener(isOn =>
- {
- Debug.unityLogger.logEnabled = isOn;
- });
- if (dspOnlyDetection != null)
- {
- dspOnlyDetection.isOn = true;
- }
- userHeightSlider.value = 170.0f / 200;
- userHeightText.text = $"User Height :{(int)(userHeightSlider.value * 200)}";
- userHeightSlider.onValueChanged.AddListener(value =>
- {
- userHeightText.text = $"User Height :{(int)(userHeightSlider.value * 200)}";
- GesEventInput.Instance.SetUserHeight((int)(userHeightSlider.value * 200));
- });
- headHandToggle.onValueChanged.AddListener(value =>
- {
- if (value)
- {
- GesEventInput.Instance.ActiveHandOrHeadHand(HandOrHeadHandType.HeadHand);
- }
- else
- {
- GesEventInput.Instance.ActiveHandOrHeadHand(HandOrHeadHandType.NormalHand);
- }
- });
- }
- /// <summary>
- /// 是否使用鱼眼校正,0-否,1-是
- /// </summary>
- public void SetUseFishEyeDistort(int useFishEyeDistort)
- {
- NativeInterface.NativeAPI.SetUseFishEyeDistort(useFishEyeDistort);
- }
- /// <summary>
- /// 0 是 检测 和 跟踪都不开 dsp
- /// 1 是 检测开 跟踪不开
- /// 2 是 检测不开 跟踪开
- /// 3 是 都开
- /// </summary>
- public void SetUseDsp(int useDsp)
- {
- RKLog.KeyInfo("SetUseDsp:" + useDsp);
- NativeInterface.NativeAPI.SetUseDsp(useDsp);
- }
- }
- }
|