public static PXR_ProjectSetting GetProjectConfig()
        {
            PXR_ProjectSetting projectConfig = Resources.Load <PXR_ProjectSetting>("ProjectSetting");

#if UNITY_EDITOR
            if (projectConfig == null)
            {
                projectConfig = CreateInstance <PXR_ProjectSetting>();
                projectConfig.useContentProtect = false;
                UnityEditor.AssetDatabase.CreateAsset(projectConfig, "Packages/com.unity.xr.picoxr/Assets/Resources/ProjectSetting.asset");
            }
#endif
            return(projectConfig);
        }
        // Start is called before the first frame update
        void Awake()
        {
            PXR_Plugin.UPxr_InitAndroidClass();
            PXR_Plugin.System.UPxr_SetSecure(PXR_ProjectSetting.GetProjectConfig().useContentProtect);
            PXR_Plugin.PlatformSetting.UPxr_BindVerifyService(gameObject.name);
            eyeCamera = Camera.main;
            Camera.main.depthTextureMode = DepthTextureMode.Depth;
#if !UNITY_EDITOR
            int fps  = -1;
            int rate = (int)GlobalIntConfigs.TargetFrameRate;
            PXR_Plugin.System.UPxr_GetIntConfig(rate, ref fps);
            float freshRate = 0.0f;
            int   frame     = (int)GlobalFloatConfigs.DisplayRefreshRate;
            PXR_Plugin.System.UPxr_GetFloatConfig(frame, ref freshRate);
            Application.targetFrameRate = fps > 0 ? fps : (int)freshRate;
            if (!useDefaultFps)
            {
                if (customFps <= freshRate)
                {
                    Application.targetFrameRate = customFps;
                }
                else
                {
                    Application.targetFrameRate = (int)freshRate;
                }
            }
#endif
            UpateSystemFFRLevel();
            if (foveationLevel != FoveationLevel.None)
            {
                PXR_Plugin.Render.UPxr_EnableFoveation(true);
                PXR_Plugin.Render.UPxr_SetFoveationLevel(foveationLevel);
            }
            PXR_Plugin.System.UPxr_InitKeyEventManager();
            PXR_Plugin.System.UPxr_StartReceiver();
            //version log
            Debug.Log("XR Platform----SDK Version:" + PXR_Plugin.System.UPxr_GetSDKVersion() + " Unity Script Version:" + PXR_Plugin.System.UPxr_GetUnitySDKVersion());
        }
Example #3
0
        public override bool Initialize()
        {
#if UNITY_INPUT_SYSTEM
            InputLayoutLoader.RegisterInputLayouts();
#endif
#if UNITY_ANDROID
            PXR_Settings settings = GetSettings();
            float        rate     = -1.0f;
            switch (settings.systemDisplayFrequency)
            {
            case PXR_Settings.SystemDisplayFrequency.Default:
            {
                rate = 0.0f;
                break;
            }

            case PXR_Settings.SystemDisplayFrequency.RefreshRate72:
            {
                rate = 72.0f;
                break;
            }

            case PXR_Settings.SystemDisplayFrequency.RefreshRate90:
            {
                rate = 90.0f;
                break;
            }

            case PXR_Settings.SystemDisplayFrequency.RefreshRate120:
            {
                rate = 120.0f;
                break;
            }
            }
            if (settings != null)
            {
                UserDefinedSettings userDefinedSettings = new UserDefinedSettings
                {
                    stereoRenderingMode    = (ushort)settings.GetStereoRenderingMode(),
                    colorSpace             = (ushort)((QualitySettings.activeColorSpace == ColorSpace.Linear) ? 1 : 0),
                    useContentProtect      = PXR_ProjectSetting.GetProjectConfig().useContentProtect,
                    systemDisplayFrequency = rate,
                };

                PXR_Plugin.System.UPxr_Construct(ConvertRotationWith2Vector);
                PXR_Plugin.System.UPxr_SetUserDefinedSettings(userDefinedSettings);
            }
#endif
            CreateSubsystem <XRDisplaySubsystemDescriptor, XRDisplaySubsystem>(displaySubsystemDescriptors, "PicoXR Display");
            CreateSubsystem <XRInputSubsystemDescriptor, XRInputSubsystem>(inputSubsystemDescriptors, "PicoXR Input");
#if UNITY_ANDROID
            CreateSubsystem <PXR_PassThroughDescriptor, PXR_PassThroughSystem>(cameraSubsystemDescriptors, "PicoXR Camera");
#endif

            if (displaySubsystem == null && inputSubsystem == null)
            {
                Debug.LogError("PXRLog Unable to start Pico XR Plugin.");
            }
            else if (displaySubsystem == null)
            {
                Debug.LogError("PXRLog Failed to load display subsystem.");
            }
            else if (inputSubsystem == null)
            {
                Debug.LogError("PXRLog Failed to load input subsystem.");
            }
            else
            {
                PXR_Plugin.System.UPxr_InitializeFocusCallback();
            }

#if UNITY_ANDROID
            if (passThroughSystem == null)
            {
                Debug.LogError("PXRLog Failed to load passThrough system.");
            }
#endif

            return(displaySubsystem != null);
        }