docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    AR Face Manager component

    The ARFaceManager component is a type of trackable manager that detects and tracks human faces in the physical environment. As a trackable manager, the AR Face Manager creates GameObjects in your scene for each detected face.

    AR Face Manager component
    AR Face Manager component

    Property Description
    trackables Changed Invoked when trackables have changed (been added, updated, or removed).
    Face Prefab If not null, this prefab is instantiated for each detected face. If the prefab does not contain an AR Face component, ARFaceManager will add one.
    Maximum Face Count The maximum number of faces to track simultaneously.

    Get started

    Add an AR Face Manager component to your XR Origin GameObject to enable face tracking in your app. If your scene doesn't contain an XR Origin GameObject, first follow the Scene setup instructions.

    Whenever your app doesn't need face tracking functionality, disable the AR Face Manager component to disable face tracking, which can improve app performance. If the user's device doesn't support face tracking, the AR Face Manager component will disable itself during OnEnable.

    Respond to detected faces

    While enabled, the AR Face Manager component will get changes reported by the XRFaceSubsystem every frame. If any faces were added, updated, or removed, the trackablesChanged event is invoked with the relevant information.

    When a face is detected, a GameObject is instantiated with an attached ARFace component, which contains data about the detected face. Refer to AR Face component to learn more about the trackable life cycle.

    You can subscribe to trackablesChanged in one of two ways:

    1. Use the Inspector

      1. Create a public method on a MonoBehavior or ScriptableObject with a single parameter of type ARTrackablesChangedEventArgs<ARFace>, as shown in the following example code:
      public void OnTrackablesChanged(ARTrackablesChangedEventArgs<ARFace> changes)
      {
          foreach (var face in changes.added)
          {
              // handle added faces
          }
      
          foreach (var face in changes.updated)
          {
              // handle updated faces
          }
      
          foreach (var face in changes.removed)
          {
              // handle removed faces
          }
      }
      
      1. Select your XR Origin GameObject, then click the Add (+) button on the AR Face Manger component's trackablesChanged property.

      2. Using the Object picker (⊙), select either a GameObject that contains an instance of your component or an instance of your ScriptableObject, whichever is applicable.

      ARFaceManager's trackablesChanged event is shown in the Inspector with a subscribed MonoBehavior
      Subscribe to the trackablesChanged event

      1. In the dropdown, select your class name and the name of your method. The method name appears in the Dynamic section of the methods list.
    2. Use C# scripting

      1. Create a public method with a single parameter of type ARTrackablesChangedEventArgs<Face> as shown in step 1a.

      2. Use the following example code to subscribe to the trackablesChanged event:

      void SubscribeToFacesChanged()
      {
          // This is inefficient. You should re-use a saved reference instead.
          var manager = Object.FindAnyObjectByType<ARFaceManager>();
      
          manager.trackablesChanged.AddListener(OnTrackablesChanged);
      }
      
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)