IEnumerator Restart(OpenXRLoaderBase loader, bool shouldRestart, Action shutdownCallback, Action restartCallback) { XRGeneralSettings.Instance.Manager.StopSubsystems(); yield return(null); XRGeneralSettings.Instance.Manager.DeinitializeLoader(); yield return(null); shutdownCallback(); if (shouldRestart) { yield return(XRGeneralSettings.Instance.Manager.InitializeLoader()); yield return(null); XRGeneralSettings.Instance.Manager.StartSubsystems(); yield return(null); if (XRGeneralSettings.Instance.Manager.activeLoader != null) { Debug.Log("Successful restart."); } else { Debug.LogError("Failure to restart OpenXRLoader after shutdown."); } restartCallback(); } GameObject.Destroy(gameObject); }
static void CreateRestarter(OpenXRLoaderBase loader, bool shouldRestart) { if (shouldRestart) { loader.GetRestarter().ShutdownAndRestartLoader(loader, () => { loader.ShutdownCompleted(); }, () => { loader.RestartCompleted(); }); } else { loader.GetRestarter().ShutdownLoader(loader, () => { loader.ShutdownCompleted(); }); } }
internal void ShutdownAndRestartLoader(OpenXRLoaderBase loader, Action shutdownCallback, Action restartCallback) { StartCoroutine(Restart(loader, true, shutdownCallback, restartCallback)); }
internal void ShutdownLoader(OpenXRLoaderBase loader, Action shutdownCallback) { StartCoroutine(Restart(loader, false, shutdownCallback, () => {})); }