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, |
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
OnDisable()
Callback when the manager is disabled.
Declaration
protected override void OnDisable()
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 |
|
Remarks
Note
The intrinsics may change each frame. You should call this each frame that you need intrinsics in order to ensure you are using the intrinsics for the current frame.
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.
Note
Starting November 2022, this method will always return false
and not acquire a camera image on
Android platforms due to API deprecation in ARCore SDK. Update to package version 4.x or higher to use
supported version of the API. See https://developers.google.com/ar/develop/unity-arf/ndk-camera-deprecation.
This methods will not be affected on iOS platforms and will continue to work same as before.
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> |