成功检测到一台处于正常运行状态的 XR 设备。
此属性已弃用,将在未来版本中删除。
请尝试获取 XRDisplaySubsystem 来确定其是否正在运行,如下例所示。
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
internal static class ExampleUtil
{
public static bool isPresent()
{
var xrDisplaySubsystems = new List<XRDisplaySubsystem>();
SubsystemManager.GetInstances<XRDisplaySubsystem>(xrDisplaySubsystems);
foreach (var xrDisplay in xrDisplaySubsystems)
{
if (xrDisplay.running)
{
return true;
}
}
return false;
}
}
public class CheckXRDisplay : MonoBehaviour
{
void Awake()
{
Debug.Log("Do we have an Active Display? " + ExampleUtil.isPresent().ToString());
}
}