Class MetaOpenXRCameraSubsystem
The Meta-OpenXR implementation of the XRCameraSubsystem. Do not create this directly. Use the SubsystemManager instead.
Inheritance
Implements
Inherited Members
Namespace: UnityEngine.XR.OpenXR.Features.Meta
Assembly: Unity.XR.MetaOpenXR.dll
Syntax
[Preserve]
public sealed class MetaOpenXRCameraSubsystem : XRCameraSubsystem, ISubsystem
Properties
cpuImageApi
The CPU image API used to construct XRCpuImage from XRCpuImage.Cinfo returned by TryAcquireLatestCpuImageForPosition(CameraPosition, out Cinfo) or TryAcquireLatestStereoCpuImagePair(out XRCpuImagePair).
Declaration
public XRCpuImage.Api cpuImageApi { get; }
Property Value
| Type | Description |
|---|---|
| XRCpuImage.Api |
Methods
GetAvailableCameras()
Gets the available cameras on this device.
Declaration
public MetaOpenXRCameraSubsystem.AvailableCameras GetAvailableCameras()
Returns
| Type | Description |
|---|---|
| MetaOpenXRCameraSubsystem.AvailableCameras | A bitfield of available cameras. The bits that are set indicate which cameras are available. |
ReleaseGpuImage(XRTextureDescriptor)
Releases a previously successfully acquired native texture descriptor.
Declaration
public void ReleaseGpuImage(XRTextureDescriptor descriptor)
Parameters
| Type | Name | Description |
|---|---|---|
| XRTextureDescriptor | descriptor | The texture descriptor that was returned by TryAcquireLatestGpuImage(out XRTextureDescriptor). |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when the provided descriptor does not match the currently held GPU image. |
ReleaseGpuImageForPosition(CameraPosition, XRTextureDescriptor)
Releases a previously successfully acquired GPU image for the specified camera.
Declaration
public void ReleaseGpuImageForPosition(MetaOpenXRCameraSubsystem.CameraPosition position, XRTextureDescriptor descriptor)
Parameters
| Type | Name | Description |
|---|---|---|
| MetaOpenXRCameraSubsystem.CameraPosition | position | The camera position that the image was acquired from. |
| XRTextureDescriptor | descriptor | The texture descriptor that was returned by TryAcquireLatestGpuImageForPosition(CameraPosition, out XRTextureDescriptor). |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when |
ReleaseStereoGpuImagePair(XRTextureDescriptorPair)
Releases a previously acquired stereo GPU image pair.
Declaration
public void ReleaseStereoGpuImagePair(MetaOpenXRCameraSubsystem.XRTextureDescriptorPair descriptorPair)
Parameters
| Type | Name | Description |
|---|---|---|
| MetaOpenXRCameraSubsystem.XRTextureDescriptorPair | descriptorPair | The stereo pair (left and right camera texture descriptors) to release. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when attempted release of pairs were not acquired together. |
SetMaxStereoSyncAttempts(int)
Sets the maximum number of sync attempts when matching stereo pair timestamps. Use a higher value (e.g. 5–10) if the cameras are not stereo synced and stereo acquire often fails. Clamped to 1–10. Default is 3. Can be called before or after the subsystem starts.
Declaration
public static void SetMaxStereoSyncAttempts(int maxAttempts)
Parameters
| Type | Name | Description |
|---|---|---|
| int | maxAttempts | Maximum number of sync attempts (1–10) |
SupportsStereoImageCapture()
Queries whether synchronized stereo image capture (both cameras from the same frame) is supported on this device.
Declaration
public bool SupportsStereoImageCapture()
Returns
| Type | Description |
|---|---|
| bool |
|
TryAcquireLatestCpuImageForPosition(CameraPosition, out Cinfo)
Acquires the latest CPU image for the requested camera.
Use TryAcquireLatestCpuImage(out XRCpuImage) for the default (mono) image or this method for a specific camera.
Declaration
public bool TryAcquireLatestCpuImageForPosition(MetaOpenXRCameraSubsystem.CameraPosition position, out XRCpuImage.Cinfo cameraImageCinfo)
Parameters
| Type | Name | Description |
|---|---|---|
| MetaOpenXRCameraSubsystem.CameraPosition | position | The camera position to acquire the image from (LeftEye or RightEye). |
| XRCpuImage.Cinfo | cameraImageCinfo | The metadata required to construct a XRCpuImage. |
Returns
| Type | Description |
|---|---|
| bool |
|
TryAcquireLatestGpuImage(out XRTextureDescriptor)
Attempts to acquire the texture descriptor for a camera GPU image as a native texture.
Declaration
public bool TryAcquireLatestGpuImage(out XRTextureDescriptor descriptor)
Parameters
| Type | Name | Description |
|---|---|---|
| XRTextureDescriptor | descriptor | The descriptor to fill in with the texture information if successful. |
Returns
| Type | Description |
|---|---|
| bool |
|
TryAcquireLatestGpuImageForPosition(CameraPosition, out XRTextureDescriptor)
Attempts to acquire the texture descriptor for GPU image for the specified camera.
Declaration
public bool TryAcquireLatestGpuImageForPosition(MetaOpenXRCameraSubsystem.CameraPosition position, out XRTextureDescriptor descriptor)
Parameters
| Type | Name | Description |
|---|---|---|
| MetaOpenXRCameraSubsystem.CameraPosition | position | The camera position to acquire the image from. |
| XRTextureDescriptor | descriptor | The descriptor to fill in with the texture information if successful. |
Returns
| Type | Description |
|---|---|
| bool |
|
TryAcquireLatestStereoCpuImagePair(out XRCpuImagePair)
Attempts to acquire a synchronized stereo pair of CPU images (both cameras from the same capture request).
Returns false if stereo is not available or the latest left/right frames are not synchronized.
The pair can be turned into XRCpuImage instances via cpuImageApi.
Declaration
public bool TryAcquireLatestStereoCpuImagePair(out MetaOpenXRCameraSubsystem.XRCpuImagePair pairImageCinfo)
Parameters
| Type | Name | Description |
|---|---|---|
| MetaOpenXRCameraSubsystem.XRCpuImagePair | pairImageCinfo | The left and right image metadata if successful. |
Returns
| Type | Description |
|---|---|
| bool |
|
TryAcquireLatestStereoGpuImagePair(out XRTextureDescriptorPair)
Attempts to acquire a synchronized stereo pair of GPU images (both cameras from the same capture request).
Only available when using logical camera approach. Returns false if images are not synchronized.
Declaration
public bool TryAcquireLatestStereoGpuImagePair(out MetaOpenXRCameraSubsystem.XRTextureDescriptorPair descriptorPair)
Parameters
| Type | Name | Description |
|---|---|---|
| MetaOpenXRCameraSubsystem.XRTextureDescriptorPair | descriptorPair | The texture descriptors for the left and right camera if successful. |
Returns
| Type | Description |
|---|---|
| bool |
|
TryGetFrameForPosition(CameraPosition, XRCameraParams, out XRCameraFrame)
Gets the camera frame for the requested camera.
Use TryGetLatestFrame(XRCameraParams, out XRCameraFrame) for the default (mono) frame or this method for a specific camera.
Declaration
public bool TryGetFrameForPosition(MetaOpenXRCameraSubsystem.CameraPosition position, XRCameraParams cameraParams, out XRCameraFrame cameraFrame)
Parameters
| Type | Name | Description |
|---|---|---|
| MetaOpenXRCameraSubsystem.CameraPosition | position | Which camera to get the frame for (LeftEye or RightEye). |
| XRCameraParams | cameraParams | Parameters used for frame conversion (e.g. screen dimensions). |
| XRCameraFrame | cameraFrame | The camera frame data if successful. |
Returns
| Type | Description |
|---|---|
| bool |
|
TryGetIntrinsicsForPosition(CameraPosition, out XRCameraIntrinsics)
Gets the camera intrinsics for the requested camera.
Use TryGetIntrinsics(out XRCameraIntrinsics) for the default (mono) intrinsics or this method for a specific camera.
Declaration
public bool TryGetIntrinsicsForPosition(MetaOpenXRCameraSubsystem.CameraPosition position, out XRCameraIntrinsics cameraIntrinsics)
Parameters
| Type | Name | Description |
|---|---|---|
| MetaOpenXRCameraSubsystem.CameraPosition | position | Which camera to get the intrinsics for (LeftEye or RightEye). |
| XRCameraIntrinsics | cameraIntrinsics | The camera intrinsics if successful. |
Returns
| Type | Description |
|---|---|
| bool |
|