Class ARCameraManager
Manages the lifetime of the XRCameraSubsystem. Add one of these to a Camera in your scene
if you want camera texture and light estimation information to be available.
Inheritance
Inherited Members
Namespace: UnityEngine.XR.ARFoundation
Syntax
public sealed class ARCameraManager : SubsystemLifecycleManager<XRCameraSubsystem, XRCameraSubsystemDescriptor>
Properties
currentConfiguration
The current camera configuration.
Declaration
public XRCameraConfiguration? currentConfiguration { get; set; }
Property Value
| Type | Description |
|---|---|
| Nullable<XRCameraConfiguration> | The current camera configuration, if it exists. Otherise, |
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | Thrown when setting the current configuration if the implementation does not support camera configurations. |
| ArgumentNullException | Thrown when setting the current configuration if the given
configuration is |
| ArgumentException | Thrown when setting the current configuration if the given configuration is not a supported camera configuration. |
| InvalidOperationException | Thrown when setting the current configuration if the implementation is unable to set the current camera configuration. |
focusMode
The CameraFocusMode for the camera.
Declaration
public CameraFocusMode focusMode { get; set; }
Property Value
| Type | Description |
|---|---|
| CameraFocusMode | The focus mode for the camera. |
lightEstimationMode
The LightEstimationMode for the camera.
Declaration
public LightEstimationMode lightEstimationMode { get; set; }
Property Value
| Type | Description |
|---|---|
| LightEstimationMode | The light estimation mode for the camera. |
permissionGranted
Determines whether camera permission has been granted.
Declaration
public bool permissionGranted { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
|
shaderName
The name of the shader used in background rendering.
Declaration
public string shaderName { get; }
Property Value
| Type | Description |
|---|---|
| String | The name of the shader used in background rendering. |
Methods
GetConfigurations(Allocator)
Get the camera configurations currently supported for the implementation.
Declaration
public NativeArray<XRCameraConfiguration> GetConfigurations(Allocator allocator)
Parameters
| Type | Name | Description |
|---|---|---|
| Allocator | allocator | The allocation strategy to use for the returned data. |
Returns
| Type | Description |
|---|---|
| NativeArray<XRCameraConfiguration> | The supported camera configurations. |
OnBeforeStart()
Callback before the subsystem is started (but after it is created).
Declaration
protected override void OnBeforeStart()
Overrides
TryGetIntrinsics(out XRCameraIntrinsics)
Tries to get camera intrinsics. Camera intrinsics refers to properties of a physical camera which may be useful when performing additional computer vision processing on the camera image.
Declaration
public bool TryGetIntrinsics(out XRCameraIntrinsics cameraIntrinsics)
Parameters
| Type | Name | Description |
|---|---|---|
| XRCameraIntrinsics | cameraIntrinsics | The camera intrinsics to be populated if the camera supports intrinsics |
Returns
| Type | Description |
|---|---|
| Boolean |
|
TryGetLatestImage(out XRCameraImage)
Attempt to get the latest camera image. This provides directly access to the raw pixel data, as well as utilities to convert to RGB and Grayscale formats.
Declaration
public bool TryGetLatestImage(out XRCameraImage cameraImage)
Parameters
| Type | Name | Description |
|---|---|---|
| XRCameraImage | cameraImage | A valid |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Remarks
The XRCameraImage must be disposed to avoid resource leaks.
Events
frameReceived
An event which fires each time a new camera frame is received.
Declaration
public event Action<ARCameraFrameEventArgs> frameReceived
Event Type
| Type | Description |
|---|---|
| Action<ARCameraFrameEventArgs> |