Skip to main content

Unity Face AR SDK Getting Started

Unity Face AR SDK allows developers to create cross-platform face tracking apps in Unity3D with custom Snapchat-like lenses, animated effects, face filters and 3D masks.

note

If you have any issues when running the Banuba Face AR plugin, please refer to the troubleshooting section or contact our support.

Requirements

  • Latest Unity Hub with latest installed Unity
  • Installed Unity platform plugins for each required platform: Android, iOS or Desktop
  • Windows: Before launching Unity you should check presence of the following tools in Microsoft VS2019:

Image

1. Banuba Face AR plugin for Unity

Get the client token
To start working with the Face AR Business plugin for Unity, you need to have the client token. To receive the client token please fill in our form on banuba.com website, or contact us via info@banuba.com.

Before opening and building the Demo project, place your client token inside appropriate file in the following location: Assets/BanubaFaceAR/Resources/BanubaClientToken.txt.

2. Preparation

  1. Run Unity Hub and add the BanubaSDK Unity project which comes with SDK Archive. image

  2. In the project files tree find and open SampleScene.unity under Assets -> BanubaFaceAR -> BaseAssets -> Scenes. Now you should see a sample scene active in the Unity Scene section. image

  3. To select mask enable checkbox in the Inspector for the required object. You can find masks in Hierarchy window under Effects -> FacesController -> Face0 -> FaceMesh. image

  4. Click the "Play" button in Unity to check how the SampleScene works on the desktop.

3. Launching on platforms

iOS

note

iOS plugin for Unity is required

  1. In Unity open File -> Build Settings
  2. Check that both LoaderScene and SampleScene checkboxes are marked with ticks and have indexes 0 and 1 respectively
  3. Select iOS platform in the platforms list in the left column
  4. Click the "Switch Platform" button image
  5. Once the platform is switched, click "Build And Run" button in the same window
  6. Specify the location and the name for Unity xCode project
  7. The project will run automatically if build succeeded OR you can open Unity-iPhone.xcodeproj file from the folder with the generated xCode project
  8. Sign the project in xCode and launch the app

MacOS

  1. In Project window find and select BNBRecognizer.bundle under Assets -> Plugins -> MacOS. Then in Inspector select Any CPU in Platform settings -> Mac OS X -> CPU dropbox
  2. In Unity open File -> Build Settings
  3. Select MacOS platform in the platforms list in the left column
  4. Click "Switch Platform" button
  5. Once the platform is switched, select Intel 64-bit + Apple silicon in Architecture dropbox and click "Build" button in the same window
  6. Specify the location and the name for MacOS executable

Windows

  1. In Unity open File -> Build Settings
  2. Select MacOS platform in the platforms list in the left column
  3. Click "Switch Platform" button
  4. Once the platform is switched, click "Build" button in the same window
  5. Specify the location and the name for MacOS executable

Android

note

Android plugin for Unity is required

  1. In Unity open File -> Build Settings
  2. Check that both LoaderScene and SampleScene checkboxes are marked with ticks and have indexes 0 and 1 respectively
  3. Select Android platform in the platforms list in the left column
  4. Click "Switch Platform" button image
  5. Check that device is updated or click "Refresh" button
  6. Once the platform is switched, click "Build And Run" button in the same window
  7. Specify the location and the name for Android .apk file
  8. The .apk will run automatically if build succeeded OR you can install the generated .apk with adb or directly from your device