private void StopInternal() { OpenXRFeature.ReceiveLoaderEvent(this, OpenXRFeature.LoaderEvent.SubsystemStop); if (inputSubsystem?.running ?? false) { StopSubsystem <XRInputSubsystem>(); } if (displaySubsystem?.running ?? false) { StopSubsystem <XRDisplaySubsystem>(); } OpenXRInput.Stop(); Internal_EndSession(); }
private bool StartInternal() { // In order to get XrReady, we have to at least attempt to create // the session if it isn't already there. if (!Internal_CreateSessionIfNeeded()) { return(false); } if (currentOpenXRState != OpenXRFeature.NativeEvent.XrReady || (currentLoaderState != LoaderState.StartAttempted && currentLoaderState != LoaderState.Started)) { return(true); } // calls xrBeginSession Internal_BeginSession(); OpenXRInput.AttachActionSets(); // Note: Display has to be started before Input so that Input can have access to the Session object StartSubsystem <XRDisplaySubsystem>(); if (!displaySubsystem?.running ?? false) { return(false); } StartSubsystem <XRInputSubsystem>(); if (!inputSubsystem?.running ?? false) { return(false); } OpenXRFeature.ReceiveLoaderEvent(this, OpenXRFeature.LoaderEvent.SubsystemStart); return(true); }
/// <summary> /// See [XRLoader.DeInitialize](xref:UnityEngine.XR.Management.XRLoader.Stop) /// </summary> /// <returns>True if deinitialized, false otherwise.</returns> public override bool Deinitialize() { if (currentLoaderState == LoaderState.Uninitialized) { return(true); } if (!validLoaderDeinitStates.Contains(currentLoaderState)) { return(false); } currentLoaderState = LoaderState.DeinitializeAttempted; try { #if TEST_SUPPORT if (ShouldExitEarly()) { return(false); } // The test hook above will leave the loader in a half initialized state. To work // around this we reset the instance pointer if it is missing. if (Instance == null) { Instance = this; } #endif Application.onBeforeRender -= ProcessOpenXRMessageLoop; ProcessOpenXRMessageLoop(); // Drain any remaining events. OpenXRFeature.ReceiveLoaderEvent(this, OpenXRFeature.LoaderEvent.SubsystemDestroy); DestroySubsystem <XRInputSubsystem>(); DestroySubsystem <XRDisplaySubsystem>(); DiagnosticReport.DumpReport("System Shutdown"); Internal_DestroySession(); ProcessOpenXRMessageLoop(); Internal_UnloadOpenXRLibrary(); currentLoaderState = LoaderState.Uninitialized; if (unhandledExceptionHandler != null) { AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException -= unhandledExceptionHandler; unhandledExceptionHandler = null; } return(base.Deinitialize()); } finally { // Ensure we always clear the instance reference even if some part of Deinitialize threw an exception Instance = null; } }
private bool InitializeInternal() { Instance = this; currentLoaderState = LoaderState.InitializeAttempted; #if TEST_SUPPORT if (ShouldExitEarly()) { return(false); } #endif #if UNITY_EDITOR if (!DisableValidationChecksOnEnteringPlaymode) { if (OpenXRProjectValidation.LogPlaymodeValidationIssues()) { return(false); } } #endif OpenXRFeature.Initialize(); if (!LoadOpenXRSymbols()) { Debug.LogError("Failed to load openxr runtime loader."); return(false); } // Sort the features array by priority in descending order (highest priority first) OpenXRSettings.Instance.features = OpenXRSettings.Instance.features .Where(f => f != null) .OrderByDescending(f => f.priority) .ThenBy(f => f.nameUi) .ToArray(); OpenXRFeature.HookGetInstanceProcAddr(); if (!Internal_InitializeSession()) { return(false); } SetApplicationInfo(); RequestOpenXRFeatures(); RegisterOpenXRCallbacks(); if (null != OpenXRSettings.Instance) { OpenXRSettings.Instance.ApplySettings(); } if (!CreateSubsystems()) { return(false); } if (OpenXRFeature.requiredFeatureFailed) { return(false); } OpenXRAnalytics.SendInitializeEvent(true); OpenXRFeature.ReceiveLoaderEvent(this, OpenXRFeature.LoaderEvent.SubsystemCreate); OpenXRInput.Initialize(); DebugLogEnabledSpecExtensions(); Application.onBeforeRender += ProcessOpenXRMessageLoop; currentLoaderState = LoaderState.Initialized; return(true); }