ImmersalLocalizerController.cs 876 B

123456789101112131415161718192021222324252627282930313233
  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 = 2f;
  11. private float time = 0f;
  12. private bool startLocalizer=false;
  13. private void Awake()
  14. {
  15. this.SubscribeEvent<SelectEnterSceneEvent>(e=>
  16. {
  17. XRLocalizer = GameObject.Find("ImmersalSDK").GetComponent<XRLocalizer>(); // 获取XRLocalizer
  18. this.enabled = true; // 开启脚本
  19. startLocalizer = true; // 开始定位
  20. });
  21. }
  22. void Update()
  23. {
  24. time += Time.deltaTime;
  25. if(time > 2 && startLocalizer)
  26. {
  27. XRLocalizer.Localize();
  28. time= 0;
  29. }
  30. }
  31. }