Forum Discussion
ManInBl4ck
2 years agoExplorer
Meta XR Simulator starts only once
Hi, I have a problem with the Meta XR Simulator v60 in Unity 2023.2.7f1 and Meta SDK v60. When i start a Synthetic Environment Server, set the simulator to active and start the game, everything work...
- 2 years ago
Think i found a solution, based on this.
If anybody should have the same problem, just place that script as a component somewhere in the scene. It ensures, that stuff is correctly uninitialized before re-initializing:
using UnityEngine; using UnityEngine.XR.Management; using System.Collections; public class VRInit : MonoBehaviour { #if UNITY_EDITOR private void Start() { EnableXR(); } private void OnDestroy() { DisableXR(); } public void EnableXR() { StartCoroutine(StartXRCoroutine()); } public void DisableXR() { XRGeneralSettings.Instance?.Manager?.StopSubsystems(); XRGeneralSettings.Instance?.Manager?.DeinitializeLoader(); } public IEnumerator StartXRCoroutine() { if(XRGeneralSettings.Instance == null){ XRGeneralSettings.Instance = XRGeneralSettings.CreateInstance<XRGeneralSettings>(); } if(XRGeneralSettings.Instance.Manager == null){ yield return new WaitUntil( () => XRGeneralSettings.Instance.Manager != null); } XRGeneralSettings.Instance?.Manager?.InitializeLoaderSync(); if (XRGeneralSettings.Instance?.Manager?.activeLoader == null){ Debug.LogError("Initializing XR Failed. Check Editor or Player log for details."); } else { XRGeneralSettings.Instance?.Manager?.StartSubsystems(); } } #endif }
ManInBl4ck
2 years agoExplorer
Think i found a solution, based on this.
If anybody should have the same problem, just place that script as a component somewhere in the scene. It ensures, that stuff is correctly uninitialized before re-initializing:
using UnityEngine;
using UnityEngine.XR.Management;
using System.Collections;
public class VRInit : MonoBehaviour {
#if UNITY_EDITOR
private void Start() {
EnableXR();
}
private void OnDestroy() {
DisableXR();
}
public void EnableXR() {
StartCoroutine(StartXRCoroutine());
}
public void DisableXR() {
XRGeneralSettings.Instance?.Manager?.StopSubsystems();
XRGeneralSettings.Instance?.Manager?.DeinitializeLoader();
}
public IEnumerator StartXRCoroutine() {
if(XRGeneralSettings.Instance == null){
XRGeneralSettings.Instance = XRGeneralSettings.CreateInstance<XRGeneralSettings>();
}
if(XRGeneralSettings.Instance.Manager == null){
yield return new WaitUntil( () => XRGeneralSettings.Instance.Manager != null);
}
XRGeneralSettings.Instance?.Manager?.InitializeLoaderSync();
if (XRGeneralSettings.Instance?.Manager?.activeLoader == null){
Debug.LogError("Initializing XR Failed. Check Editor or Player log for details.");
}
else {
XRGeneralSettings.Instance?.Manager?.StartSubsystems();
}
}
#endif
}
- Darthmarccus1821 year agoHonored Guest
Thanks heaps man!
Also, don't forget to save and close and re-open unity after adding this script. That worked for me! 🙂 - yuanyuanjiang9 months agoHonored Guest
Thank you so much, very useful!!
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 2 years ago
- 5 months ago
- 1 year ago