API reference

PassthroughCameraAccess Class

Extends MonoBehaviour
Provides access to the Passthrough Camera Access API.

This component requires the "horizonos.permission.HEADSET_CAMERA" permission to be present in AndroidManifest.xml: <uses-permission android:name="horizonos.permission.HEADSET_CAMERA" /> See documentation: https://developers.meta.com/horizon/documentation/unity/unity-pca-overview/

Fields

CameraPosition : CameraPositionType
Requested camera position. To access both left and right camera simultaneously, create two instances of PassthroughCameraAccess with different PassthroughCameraAccess.CameraPosition
Signature
CameraPositionType CameraPosition
RequestedResolution : Vector2Int
The requested resolution of the camera. If the requested resolution is not present in GetSupportedResolutions, the first smaller resolution will be selected instead.
Signature
Vector2Int RequestedResolution
TargetMaterial : Material
Signature
Material TargetMaterial

Properties

CurrentResolution : Vector2Int
[Get]
The current resolution of the camera. May be different from the RequestedResolution.
Signature
Vector2Int CurrentResolution
Intrinsics : CameraIntrinsics
[Get]
The static intrinsic parameters of the sensor. These parameters become available after the PassthroughCameraAccess is enabled and never change after that.
Signature
CameraIntrinsics Intrinsics
IsPlaying : bool
[Get]
Indicates whether the component is enabled and has received the camera image at least once.
Signature
bool IsPlaying
IsSupported : bool
[Get]
Returns true if the current headset supports Passthrough Camera Access.
Signature
bool IsSupported
IsUpdatedThisFrame : bool
[Get]
Returns 'true' if the camera texture was updated this frame.
Signature
bool IsUpdatedThisFrame
MaxFramerate : int
[Get][Set]
Maximum framerate for the camera stream (frames per second).
The actual framerate may vary based on lighting conditions and the current workload. This property can only be changed when the component is disabled.
Signature
int MaxFramerate
TexturePropertyName : string
[Get][Set]
The name of the texture property to update.
If changed at runtime, we recache the shader property ID so that Material.SetTexture(...) uses the new name.
Signature
string TexturePropertyName
Timestamp : DateTime
[Get]
Timestamp associated with the latest camera image.
Signature
DateTime Timestamp

Methods

GetCameraPose ()
Signature
Pose GetCameraPose()
Returns
Pose
GetColors ()
Retrieves color data of the latest camera image.
Use this method to process camera images on CPU.
Do not cache, modify or dispose the contents of the returned native array.
NOTE: this method is expensive, consider using a non-blocking version of AsyncGPUReadback instead.
Signature
NativeArray< Color32 > GetColors()
Returns
NativeArray< Color32 >  Native array that contains all pixels of the captured image.
GetTexture ()
Retrieves GPU texture of the latest camera image.
Use this method to access camera images on GPU.
The texture is updated in render thread before the frame is displayed. This means that performing blocking operations such as Graphics.Blit() will pick the texture from the previous frame. To access the latest texture on CPU, use AsyncGPUReadback instead.
Signature
Texture GetTexture()
Returns
Texture  Texture with the latest camera image.
ViewportPointToRay ( viewportPoint , cameraPose )
Returns a world-space ray going from camera through a viewport point.
Signature
Ray ViewportPointToRay(Vector2 viewportPoint, Pose? cameraPose=null)
Parameters
viewportPoint: Vector2  Viewport-space is normalized and relative to the camera. The bottom-left of the camera is (0,0); the top-right is (1,1).
cameraPose: Pose?  Optional camera pose that should be used for calculation. For example, you can cache GetCameraPose, do a long-running image processing, then use the cached camera pose with this method.
Returns
Ray  World-space ray.
WorldToViewportPoint ( worldPosition , cameraPose )
Transforms worldPosition from world-space into viewport-space.
Signature
Vector2 WorldToViewportPoint(Vector3 worldPosition, Pose? cameraPose=null)
Parameters
worldPosition: Vector3  A world-space position.
cameraPose: Pose?  Optional camera pose that should be used for calculation. For example, you can cache GetCameraPose, do a long-running image processing, then use the cached camera pose with this method.
Returns
Vector2  Viewport-space coordinate. Viewport-space is normalized and relative to the camera. The bottom-left of the camera is (0,0); the top-right is (1,1).

Static Methods

GetSupportedResolutions ( cameraPosition )
Retrieves supported resolutions of the given camera.
Signature
static unsafe Vector2Int[] GetSupportedResolutions(CameraPositionType cameraPosition)
Parameters
cameraPosition: CameraPositionType  The position of the camera (Left or Right).
Returns
unsafe Vector2Int[]  An array containing all supported resolutions.

Inner Struct

CameraIntrinsics Struct

The static intrinsic parameters of the sensor.

Fields

FocalLength : Vector2
The focal length of the camera.
Signature
Vector2 FocalLength
LensOffset : Pose
The translation and orientation of the camera sensor relative to the headset.
Signature
Pose LensOffset
PrincipalPoint : Vector2
The principal point of the camera.
Signature
Vector2 PrincipalPoint
SensorResolution : Vector2Int
The sensor resolution of the camera.
Signature
Vector2Int SensorResolution

Inner Enum

CameraPositionType Enum

Possible positions of the camera (Left or Right).

Enumeration Constants

Member
Left
Right