1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- 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<GameObject>("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<Camera>();
- if (renderCam == null)
- {
- Debug.LogError("RokidMRC Package Is Invalid");
- return;
- }
- renderCam.cullingMask = UXRSDKConfig.Instance.MRCCameraRenderLayer;
- renderCam.renderingPath = UXRSDKConfig.Instance.MRCCameraRenderingPath;
- }
- }
- }
- }
- }
|