using UnityEngine; using Rokid.UXR.Config; using Rokid.UXR.Native; namespace Rokid.UXR.SubModule { [DisallowMultipleComponent] public class MRCLoader : MonoBehaviour { public static bool isMRCDriverCreated; private bool isMRCInited; void Update() { if (isMRCDriverCreated) { return; } if (!isMRCInited && UXRSDKConfig.Instance.MRCActive) { #if !UNITY_EDITOR if (NativeInterface.NativeAPI.GetHeadTrackingStatus() == HeadTrackingStatus.Tracking) #endif { isMRCInited = true; //加载MRC启动器Prefab,如果加载不到,说明未安装RokidMRC这个Package GameObject mrcDriver = Resources.Load("MRCDriver"); if (mrcDriver == null) { Debug.LogError("Please Install RokidMRC Package Through NPM"); return; } //生成MRC启动器 GameObject driver = Instantiate(mrcDriver); isMRCDriverCreated = true; //设置相机cullingMask Camera renderCam = driver.transform.Find("RenderCamera").GetComponent(); if (renderCam == null) { Debug.LogError("RokidMRC Package Is Invalid"); return; } renderCam.cullingMask = UXRSDKConfig.Instance.MRCCameraRenderLayer; renderCam.renderingPath = UXRSDKConfig.Instance.MRCCameraRenderingPath; } } } } }