public static bool isPresent ;

Description

Successfully detected a XR device in working order.

This property has been deprecated and will be removed in a future release.

Instead, try to retrieve the XRDisplaySubsystem to see if it is running, as the example below illustrates.

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());
    }
}
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961