UIOverlaySample.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using Rokid.UXR;
  2. using UnityEngine.UI;
  3. using Rokid.UXR.Module;
  4. using Rokid.UXR.Utility;
  5. using UnityEngine;
  6. public class UIOverlaySample : AutoInjectBehaviour
  7. {
  8. [Autowrited]
  9. private Button zeroDofButton;
  10. [Autowrited]
  11. private Button threeDofButton;
  12. [Autowrited]
  13. private Button sixDofButton;
  14. [Autowrited]
  15. private Toggle centerToggle;
  16. [Autowrited]
  17. private Toggle useLeftEyeFovToggle;
  18. private RKCameraRig cameraRig;
  19. private FollowCamera followCamera;
  20. private bool useLeftEyeFov = true;
  21. private bool adjustCenterByFov = true;
  22. private void Start()
  23. {
  24. cameraRig = MainCameraCache.mainCamera.transform.GetComponent<RKCameraRig>();
  25. followCamera = GameObject.Find("OverlayUI").GetComponent<FollowCamera>();
  26. zeroDofButton.onClick.AddListener(() =>
  27. {
  28. cameraRig.headTrackingType = RKCameraRig.HeadTrackingType.None;
  29. });
  30. threeDofButton.onClick.AddListener(() =>
  31. {
  32. cameraRig.headTrackingType = RKCameraRig.HeadTrackingType.RotationOnly;
  33. });
  34. sixDofButton.onClick.AddListener(() =>
  35. {
  36. cameraRig.headTrackingType = RKCameraRig.HeadTrackingType.RotationAndPosition;
  37. });
  38. centerToggle.onValueChanged.AddListener(selected =>
  39. {
  40. adjustCenterByFov = selected;
  41. followCamera.AdjustCenterByCameraByFov(adjustCenterByFov, useLeftEyeFov);
  42. });
  43. useLeftEyeFovToggle.onValueChanged.AddListener(selected =>
  44. {
  45. useLeftEyeFov = selected;
  46. followCamera.AdjustCenterByCameraByFov(adjustCenterByFov, useLeftEyeFov);
  47. });
  48. }
  49. }