AR Face component
The ARFace component is a type of trackable that contains the data associated with a detected human face. The ARFace
AR Face component
Property | Description |
---|---|
Destroy On Removal | If true , this component's GameObject is destroyed when this trackable is removed. |
Face life cycle
As trackables, AR faces have a life cycle that consists of three phases: added, updated, and removed. Your app can Respond to detected faces during your AR session by subscribing to the AR Face Manager component's trackables
Added
When a human face is first detected, the AR Face Manager creates a new GameObject with an AR Face component attached. The AR Face Manager then invokes the trackablesChanged
event. This event passes you a reference to the new AR Face component via the added property.
Updated
There are two events invoked in each frame where a face is updated, as described in the following table:
Event | Description |
---|---|
ARFace. |
Invoked when the face is updated. If face meshes are supported, there will be updated vertices, normals, indices, and uvs. Allows you to subscribe to updates of individual faces separately. |
ARFace |
This method contains a list of all changed faces in the frame. |
Tracking state
When a face leaves the device camera's field of view, the AR Face Manager might set its tracking
If your app responds to face life cycle events, you should check each face's trackingState
value whenever the face is updated.
Removed
When a face is no longer detected, the AR Face Manager might remove it. Removed faces can no longer be updated. If a removed face's Destroy On Removal property is set to true
, the AR Face Manager will destroy it immediately after invoking the trackablesChanged
event.
Important
Do not call Destroy
on any AR Face component or its GameObject. AR faces are managed by the AR Face Manager component, and destroying them yourself can result in errors. Consider disabling the GameObject or not rendering the face mesh instead.
Visualize faces in your scene
An AR Face
is represented by a mesh that consists of vertices, normals, indices, and uvs (texture coordinates). The availability of these features depends on the features supported by your chosen platform. Refer to Face tracking platform support to understand the features each face tracking provider supports.
You can add the ARFace
The AR Foundation Samples GitHub repository contains prefabs that you can use to get started, outlined in the following table.
Prefab | Description |
---|---|
Face Mesh Visualizer | Visualize the generated face mesh for a detected face. |
Custom face visualizers
You can also create your own custom face visualizer for use in your face prefab. A common way to visualize a face in your scene is to use a MeshFilter and MeshRenderer. If your custom visualizer uses one or more of these components, you can add an ARFace