using System; using System.Text; using Unity.Collections.LowLevel.Unsafe; using UnityEngine; using UnityEngine.UI; using UnityEngine.XR.ARFoundation; using UnityEngine.XR.ARSubsystems; namespace UnityEngine.XR.ARFoundation.Samples { /// /// This component tests for depth functionality and enables/disables /// a text message on the screen reporting that depth is not suppoted. /// public class CheckRuntimeDepth : MonoBehaviour { [SerializeField] [Tooltip("The AROcclusionManager which will manage depth functionality.")] AROcclusionManager m_OcclusionManager; /// /// Get or set the AROcclusionManager. /// public AROcclusionManager occlusionManager { get => m_OcclusionManager; set => m_OcclusionManager = value; } [SerializeField] Text m_DepthAvailabilityInfo; /// /// The UI Text used to display information about the availability of depth functionality. /// public Text depthAvailabilityInfo { get => m_DepthAvailabilityInfo; set => m_DepthAvailabilityInfo = value; } void Update() { Debug.Assert(m_OcclusionManager != null, "no occlusion manager"); Debug.Assert(m_DepthAvailabilityInfo != null, "no text box"); var descriptor = m_OcclusionManager.descriptor; m_DepthAvailabilityInfo.enabled = descriptor == null || (descriptor.humanSegmentationStencilImageSupported == Supported.Unsupported && descriptor.humanSegmentationDepthImageSupported == Supported.Unsupported && descriptor.environmentDepthImageSupported == Supported.Unsupported); } } }