Occlusion platform support
Occlusion is supported on the ARCore, ARKit, and XR Simulation platforms, as shown in the table below:
Provider plug-in | Occlusion supported | Provider documentation |
---|---|---|
Google ARCore XR Plug-in | Yes | Occlusion (ARCore) |
Apple ARKit XR Plug-in | Yes | Occlusion (ARKit) |
Apple visionOS XR Plug-in | ||
Microsoft HoloLens | ||
Unity OpenXR: Meta | ||
XR Simulation | Yes | Occlusion (XR Simulation) |
Check for occlusion support
Your app can check at runtime whether a provider plug-in supports occlusion on the user's device.
Use the example code below to check whether the device supports occlusion:
void Start()
{
if (LoaderUtility
.GetActiveLoader()?
.GetLoadedSubsystem<XROcclusionSubsystem>() != null)
{
// XROcclusionSubsystem was loaded. The platform supports occlusion.
}
}
Note
This example code assumes that your app has already initialized XR.
By default XR initializes automatically when your app starts, but this is configurable via Project Settings > XR Plug-in Management > Initialize XR on Startup. Refer to the XR Plug-in Management End-user documentation for more detailed information about managing the XR Plug-in lifecycle.
Optional features
The following table describes the optional features of the XROcclusionSubsystem. The Descriptor Property column provides the relevant property of the XROcclusionSubsystemDescriptor. The Description column defines the property. Refer to AR Occlusion Manager component for more information about the types of depth image described.
Feature | Descriptor Property | Description |
---|---|---|
Environment Depth Image | environmentDepthImageSupported | Whether the subsystem supports environment depth image. |
Environment Depth Confidence Image | environmentDepthConfidenceImageSupported | Whether the subsystem supports environment depth confidence image. |
Environment Depth Temporal Smoothing | environmentDepthTemporalSmoothingSupported | Whether temporal smoothing of the environment image is supported. |
Human Segmentation Stencil Image | humanSegmentationStencilImageSupported | Whether a subsystem supports human segmentation stencil image. |
Human Segmentation Depth Image | humanSegmentationDepthImageSupported | Whether a subsystem supports human segmentation depth image. |
Optional feature platform support
Occlusion providers may choose whether to implement any of the optional features of AR Foundation's XROcclusionSubsystem, as indicated in the following table:
Feature | ARCore | ARKit | XR Simulation |
---|---|---|---|
Environment Depth Image | Yes | Yes | Yes |
Environment Depth Confidence Image | Yes | Yes | |
Environment Depth Temporal Smoothing | Yes | Yes | |
Human Segmentation Stencil Image | Yes | ||
Human Segmentation Depth Image | Yes |
Check for optional feature support
Your app can check at runtime whether an occlusion provider supports any optional features on the user's device. The XROcclusionSubsystemDescriptor contains properties for each optional feature that tell you whether they are supported.
Refer to the following example code to learn how to check for optional feature support:
void CheckForOptionalFeatureSupport()
{
// This is inefficient. You should re-use a saved reference instead.
var manager = Object.FindAnyObjectByType<AROcclusionManager>();
// Use manager.descriptor to determine which optional features
// are supported on the device. For example:
if (manager.descriptor.environmentDepthImageSupported == Supported.Supported)
{
// Environment depth image is supported.
}
}
Apple and ARKit are trademarks of Apple Inc., registered in the U.S. and other countries and regions.