Table of Contents

Class UCameraManager

Class for interfacing with the native Camera2 API on Android.

public class UCameraManager : DontCreateNewSingleton<UCameraManager>
Inheritance
object
UCameraManager

Fields

AvatarCameraPermission

The permission required to access the Meta Quest's avatar camera.

public const string AvatarCameraPermission = "android.permission.CAMERA"

Field Value

string

HeadsetCameraPermission

The permission required to access the Meta Quest's Passthrough cameras.

public const string HeadsetCameraPermission = "horizonos.permission.HEADSET_CAMERA"

Field Value

string

YUVToRGBAComputeShader

The compute shader to use to convert the camera's YUV 4:2:0 images to RGBA.

public ComputeShader YUVToRGBAComputeShader

Field Value

ComputeShader

Properties

Cameras

Gets a cached array of the available cameras and their characteristics.

public CameraInfo[]? Cameras { get; }

Property Value

CameraInfo[]

Remarks

The disposal of the CameraInfo objects generated by this property are managed by the UCameraManager instance. If you require control of the CameraInfo objects, use GetCameraInfos() instead.

Methods

Awake()

protected override void Awake()

GetCamera(CameraEye)

Gets a camera device by the eye it is closest to.

public CameraInfo? GetCamera(CameraInfo.CameraEye eye)

Parameters

eye CameraInfo.CameraEye

The eye.

Returns

CameraInfo

A CameraInfo object or null if none were found.

Remarks

The CameraInfo object returned by this method is managed by the UCameraManager instance, so do not dispose it manually.

GetCameraInfos()

Gets all available cameras and their characteristics. This is not cached.

public CameraInfo[]? GetCameraInfos()

Returns

CameraInfo[]

An array of CameraInfo objects or null if any errors occurred.

Remarks

You will have to manage the disposal of the CameraInfo objects returned by this method. Use Cameras if you don't want to handle the objects yourself.

OnDestroy()

protected void OnDestroy()

OpenCamera(string)

Opens a camera device for use.

public CameraDevice? OpenCamera(string camera)

Parameters

camera string

The ID of the camera to open; accepts CameraInfo objects through an implicit cast.

Returns

CameraDevice

A CameraDevice object or null if any errors occurred.

Remarks

Once you have finished using the camera, close and dispose of it using DisposeAsync().

RefreshCachedCameraInfos()

Refreshes the cached array of camera devices.

public bool RefreshCachedCameraInfos()

Returns

bool

true if the refresh was successful; false otherwise.