Camera platform support
The AR Foundation XRCameraSubsystem is supported on the ARCore, ARKit, Meta OpenXR and XR Simulation platforms, as shown in the following table:
Provider plug-in | Camera supported | Provider documentation |
---|---|---|
Google ARCore XR Plug-in | Yes | Camera (ARCore) |
Apple ARKit XR Plug-in | Yes | Camera (ARKit) |
Apple visionOS XR Plug-in | ||
Microsoft HoloLens | ||
Unity OpenXR: Meta | Yes | Camera (Meta OpenXR) |
XR Simulation | Yes | Camera (XR Simulation) |
Check for camera support
Your app can check at runtime whether a provider plug-in supports camera components on the user's device. Use the following example code to check whether the device supports camera components:
void Start()
{
if (LoaderUtility
.GetActiveLoader()?
.GetLoadedSubsystem<XRCameraSubsystem>() != null)
{
// XRCameraSubsystem was loaded. The platform supports the camera subsystem.
}
}
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.
Note
This code example returns true
if the provider plug-in implements the camera subsystem. The availability of the camera on a specific device may not be available other reasons, for example user permissions.
Optional features
The following table lists the optional features of the camera subsystem. Each optional feature is defined by a Descriptor Property of the XRCameraSubsystemDescriptor, which you can check at runtime to determine whether a feature is supported. The Description column lists the optional API that may or may not be implemented on each platform. Refer to Check for optional feature support for a code example to check whether a feature is supported.
Tip
Check the API documentation to understand how each API behaves when the provider does not support a feature. For example, some properties throw an exception if you try to set the value when the feature is not supported.
Feature | Descriptor Property | Description |
---|---|---|
Brightness | supportsAverageBrightness | Indicates whether the provider implementation can provide a value for XRCameraFrame.averageBrightness. |
Color temperature | supportsAverageColorTemperature | Indicates whether the provider implementation can provide a value for XRCameraFrame.averageColorTemperature. |
Color correction | supportsColorCorrection | Indicates whether the provider implementation can provide a value for XRCameraFrame.colorCorrection. |
Display matrix | supportsDisplayMatrix | Indicates whether the provider implementation can provide a value for XRCameraFrame.displayMatrix. |
Projection matrix | supportsProjectionMatrix | Indicates whether the provider implementation can provide a value for XRCameraFrame.projectionMatrix. |
Timestamp | supportsTimestamp | Indicates whether the provider implementation can provide a value for XRCameraFrame.timestampNs. |
Camera configuration | supportsCameraConfigurations | Indicates whether the provider implementation supports camera configurations. |
Camera image | supportsCameraImage | Indicates whether the provider implementation can provide camera images. |
Average intensity in lumens | supportsAverageIntensityInLumens | Indicates whether the provider implementation can provide a value for XRCameraFrame.averageIntensityInLumens. |
Focus modes | supportsFocusModes | Indicates whether the provider implementation supports the ability to set the camera's focus mode. |
Face tracking ambient intensity light estimation | supportsFaceTrackingAmbientIntensityLightEstimation | Indicates whether the provider implementation supports ambient intensity light estimation while face tracking is enabled. |
Face tracking HDR light estimation | supportsFaceTrackingHDRLightEstimation | Indicates whether the provider implementation supports HDR light estimation while face tracking is enabled. |
World tracking ambient intensity light estimation | supportsWorldTrackingAmbientIntensityLightEstimation | Indicates whether the provider implementation supports ambient intensity light estimation while world tracking. |
World tracking HDR light estimation | supportsWorldTrackingHDRLightEstimation | Indicates whether the provider implementation supports HDR light estimation while world tracking. |
Camera grain | supportsCameraGrain | Indicates whether the provider implementation can provide a value for XRCameraFrame.cameraGrain. |
Image stabilization | supportsImageStabilization | Indicates whether the provider implementation supports the ability to set the camera's Image Stabilization mode. |
Exif data | supportsExifData | Indicates whether the provider implementation supports EXIF data. |
Camera torch mode | supportsCameraTorchMode | Indicates whether the provider implementation supports camera torch mode |
Optional feature platform support
To understand the optional features that are implemented in each supported XR plug-in provider, refer to the following table:
Feature | ARCore | ARKit | Meta OpenXR | XR Simulation |
---|---|---|---|---|
Brightness | Yes | Yes | ||
Color temperature | Yes | Yes | ||
Color correction | Yes | Yes | ||
Display matrix | Yes | Yes | ||
Projection matrix | Yes | Yes | ||
Timestamp | Yes | Yes | ||
Camera configurations | Yes | Yes | Yes | |
Camera image | Yes | Yes | Yes | |
Average intensity in lumens | Yes | Yes | ||
Focus modes | Yes | Yes | ||
Face tracking ambient intensity light estimation | Yes | Yes | ||
Face tracking HDR light estimation | Yes | |||
World tracking ambient intensity light estimation | Yes | Yes | ||
World tracking HDR light estimation | Yes | |||
Camera grain | iOS 13+ | |||
Image stabilization | ||||
EXIF data | Yes | iOS 16+ | ||
Camera torch mode | Yes |
Check for optional feature support
Your app can check at runtime whether a camera provider supports any optional features on the user's device. The XRCameraSubsystemDescriptor contains Boolean 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<ARCameraManager>();
// Use manager.descriptor to determine which optional features
// are supported on the device. For example:
if (manager.descriptor.supportsCameraImage)
{
// Camera image is supported.
}
}
Apple and ARKit are trademarks of Apple Inc., registered in the U.S. and other countries and regions.