branch
parent
b6df992477
commit
37d0e6e64a
@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Management;
|
||||
|
||||
public class XRControl : MonoBehaviour
|
||||
{
|
||||
private XRManagerSettings xrManager;
|
||||
|
||||
void Start()
|
||||
{
|
||||
xrManager = XRGeneralSettings.Instance.Manager;
|
||||
if (XRGeneralSettings.Instance.Manager.activeLoader == null) { StopXR(); }
|
||||
}
|
||||
|
||||
public void StartXR()
|
||||
{
|
||||
StartCoroutine(StartXRLoader());
|
||||
}
|
||||
|
||||
public void StopXR()
|
||||
{
|
||||
StartCoroutine(StopXRLoader());
|
||||
}
|
||||
|
||||
private IEnumerator StartXRLoader()
|
||||
{
|
||||
if (!xrManager.isInitializationComplete)
|
||||
{
|
||||
xrManager.InitializeLoader();
|
||||
yield return new WaitUntil(() => xrManager.isInitializationComplete);
|
||||
xrManager.StartSubsystems();
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator StopXRLoader()
|
||||
{
|
||||
if (xrManager.isInitializationComplete)
|
||||
{
|
||||
xrManager.StopSubsystems();
|
||||
xrManager.DeinitializeLoader();
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 769b401939dd60141b0d748e39469b2a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue