MRCDriver.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Android;
  5. using Rokid.MRC;
  6. namespace Rokid.MRC
  7. {
  8. public enum ARCalibrationMode
  9. {
  10. FaceTrack,
  11. SelfCalibration,
  12. }
  13. public class MRCDriver : UnitySingleton<MRCDriver>
  14. {
  15. public bool UseGlobalRenderCamera;
  16. [HideInInspector]
  17. public bool ShowAnchorUI = false;
  18. [HideInInspector]
  19. public bool ShowCompositeUI = true;
  20. public bool ShowClientAnchor = true;
  21. [HideInInspector]
  22. public Transform SelfCalibrationPhone;
  23. public override void Awake()
  24. {
  25. base.Awake();
  26. Init();
  27. }
  28. void Init()
  29. {
  30. LocalizationMgr.Instance.SetLanguage(Application.systemLanguage);
  31. SDKManager.Instance.Init();
  32. UIManager.Instance.Init();
  33. if(!UIManager.Instance.HideUISystem)
  34. {
  35. UIManager.Instance.OpenPanel(UIType.Connection);
  36. }
  37. //用于编辑器下,直接打开MRCRoot场景,导致无摄像机的情况
  38. if(Camera.main == null)
  39. {
  40. GameObject obj = new GameObject("MainCamera");
  41. obj.tag = "MainCamera";
  42. Camera camera = obj.AddComponent<Camera>();
  43. }
  44. }
  45. private void Update()
  46. {
  47. //获取位置权限
  48. if(!Permission.HasUserAuthorizedPermission(Permission.FineLocation))
  49. {
  50. Permission.RequestUserPermission(Permission.FineLocation);
  51. }
  52. if(!Permission.HasUserAuthorizedPermission(Permission.Microphone))
  53. {
  54. Permission.RequestUserPermission(Permission.Microphone);
  55. }
  56. }
  57. //当跳出设置Wifi后,重新刷新本机IP地址
  58. public void OnApplicationPause(bool pause)
  59. {
  60. if(!pause)
  61. {
  62. MessageCenter.SendMessage(GlobalDefine.RefreshConnectPanel, null);
  63. }
  64. else
  65. {
  66. TransmissionClient.Release();
  67. }
  68. }
  69. }
  70. }