ImmersalLocalizerController.cs 973 B

12345678910111213141516171819202122232425262728293031323334
  1. using Immersal.AR;
  2. using UnityEngine;
  3. using Blue;
  4. /// <summary>
  5. /// 控制Immersal定位
  6. /// </summary>
  7. public class ImmersalLocalizerController: AbstractController
  8. {
  9. [SerializeField] private XRLocalizer XRLocalizer;
  10. [SerializeField] private float rateTime = 0.5f;
  11. private float time = 0f;
  12. private bool startLocalizer=false;
  13. private void Awake()
  14. {
  15. this.RegisterEvent<StartImmersalLocalizerEvent>(e=>
  16. {
  17. XRLocalizer = GameObject.Find("ImmersalSDK").GetComponent<XRLocalizer>(); // 获取XRLocalizer
  18. this.enabled = true; // 开启脚本
  19. startLocalizer = true; // 开始定位
  20. }).UnRegisterWhenGameObjectDestroyed(gameObject);
  21. }
  22. void Update()
  23. {
  24. time += Time.deltaTime;
  25. if(time > rateTime && startLocalizer && !SetSceneActive.Instance.active)
  26. {
  27. //XRLocalizer.Localize();
  28. time= 0;
  29. }
  30. }
  31. }