Esempio n. 1
0
        public OculusSettings GetSettings()
        {
            OculusSettings settings = null;

#if UNITY_EDITOR
            UnityEditor.EditorBuildSettings.TryGetConfigObject <OculusSettings>("Unity.XR.Oculus.Settings", out settings);
#else
            settings = OculusSettings.s_Settings;
#endif
            return(settings);
        }
Esempio n. 2
0
        public override bool Initialize()
        {
#if UNITY_EDITOR
            if (!EditorLoadOVRPlugin())
            {
                return(false);
            }
#else
            if (!LoadOVRPlugin(""))
            {
                Debug.LogError("Failed to load OVRPlugin.dll");
                return(false);
            }
#endif

#if UNITY_INPUT_SYSTEM
            InputLayoutLoader.RegisterInputLayouts();
#endif

            OculusSettings settings = GetSettings();
            if (settings != null)
            {
                UserDefinedSettings userDefinedSettings;
                userDefinedSettings.sharedDepthBuffer   = (ushort)(settings.SharedDepthBuffer ? 1 : 0);
                userDefinedSettings.dashSupport         = (ushort)(settings.DashSupport ? 1 : 0);
                userDefinedSettings.stereoRenderingMode = (ushort)settings.GetStereoRenderingMode();
                userDefinedSettings.colorSpace          = (ushort)((QualitySettings.activeColorSpace == ColorSpace.Linear) ? 1 : 0);
                userDefinedSettings.lowOverheadMode     = (ushort)(settings.LowOverheadMode ? 1 : 0);
                userDefinedSettings.protectedContext    = (ushort)(settings.ProtectedContext ? 1 : 0);
                userDefinedSettings.focusAware          = (ushort)(settings.FocusAware ? 1 : 0);
                SetUserDefinedSettings(userDefinedSettings);
            }

            CreateSubsystem <XRDisplaySubsystemDescriptor, XRDisplaySubsystem>(s_DisplaySubsystemDescriptors, "oculus display");
            CreateSubsystem <XRInputSubsystemDescriptor, XRInputSubsystem>(s_InputSubsystemDescriptors, "oculus input");

            if (displaySubsystem == null || inputSubsystem == null)
            {
                Debug.LogError("Unable to start Oculus XR Plugin.");
            }

            if (displaySubsystem == null)
            {
                Debug.LogError("Failed to load display subsystem.");
            }

            if (inputSubsystem == null)
            {
                Debug.LogError("Failed to load input subsystem.");
            }

            return(displaySubsystem != null && inputSubsystem != null);
        }
Esempio n. 3
0
        public override bool Initialize()
        {
            if (IsDeviceSupported() != DeviceSupportedResult.Supported)
            {
                return(false);
            }

#if UNITY_INPUT_SYSTEM
            InputLayoutLoader.RegisterInputLayouts();
#endif // UNITY_INPUT_SYSTEM

            OculusSettings settings = GetSettings();
            if (settings != null)
            {
                NativeMethods.UserDefinedSettings userDefinedSettings;
                userDefinedSettings.sharedDepthBuffer      = (ushort)(settings.SharedDepthBuffer ? 1 : 0);
                userDefinedSettings.dashSupport            = (ushort)(settings.DashSupport ? 1 : 0);
                userDefinedSettings.stereoRenderingMode    = (ushort)settings.GetStereoRenderingMode();
                userDefinedSettings.colorSpace             = (ushort)((QualitySettings.activeColorSpace == ColorSpace.Linear) ? 1 : 0);
                userDefinedSettings.lowOverheadMode        = (ushort)(settings.LowOverheadMode ? 1 : 0);
                userDefinedSettings.protectedContext       = (ushort)(settings.ProtectedContext ? 1 : 0);
                userDefinedSettings.focusAware             = (ushort)(settings.FocusAware ? 1 : 0);
                userDefinedSettings.optimizeBufferDiscards = (ushort)(settings.OptimizeBufferDiscards ? 1 : 0);
                userDefinedSettings.phaseSync = (ushort)(settings.PhaseSync ? 1 : 0);
                NativeMethods.SetUserDefinedSettings(userDefinedSettings);
            }

            CreateSubsystem <XRDisplaySubsystemDescriptor, XRDisplaySubsystem>(s_DisplaySubsystemDescriptors, "oculus display");
            CreateSubsystem <XRInputSubsystemDescriptor, XRInputSubsystem>(s_InputSubsystemDescriptors, "oculus input");

            if (displaySubsystem == null && inputSubsystem == null)
            {
#if (UNITY_ANDROID && !UNITY_EDITOR)
                Debug.LogWarning("Unable to start Oculus XR Plugin.");
#else
                Debug.LogWarning("Unable to start Oculus XR Plugin.\n" +
                                 "Possible causes include a headset not being attached, or the Oculus runtime is not installed or up to date.\n" +
                                 "If you've recently installed or updated the Oculus runtime, you may need to reboot or close Unity and the Unity Hub and try again.");
#endif
            }
            else if (displaySubsystem == null)
            {
                Debug.LogError("Unable to start Oculus XR Plugin. Failed to load display subsystem.");
            }
            else if (inputSubsystem == null)
            {
                Debug.LogError("Unable to start Oculus XR Plugin. Failed to load input subsystem.");
            }

            ShutdownMonitor.Initialize();

            return(displaySubsystem != null && inputSubsystem != null);
        }