Using Vuforia Engine with Unity as a Library (UaaL)

Vuforia supports UaaL in Unity introduced by Unity for Android and iOS applications starting with the Unity Editor. Follow the guide below to integrate Vuforia with Unity as a Library.

NOTE: this guide has been tested with Unity 2021.3.0+.

Follow the Unity guides for UaaL setup from the links below, taking the additional Vuforia specific steps below into account.
We recommend running through the Unity guides before adding Vuforia Engine support to make sure your build setup works.

UaaL Android guide 
UaaL iOS guide

Project Setup (Android and iOS)  

To add Vuforia Engine support to the Unity Project from the guides above, import the Vuforia Engine SDK package into your project.

Now, let's add some Vuforia functionality to the provided Unity project:

  1. Open Scenes/SampleScene.
  2. Add an ARCamera GameObject to the scene by selecting GameObject -> Vuforia Engine -> ARCamera.
  3. Delete the MainCamera GameObject from the scene.
  4. Add an Image Target by selecting GameObject -> Vuforia Engine -> Image Target.
    • Confirm the dialog asking you to import the default database.
  5. Create and re-parent a Cube in the scene to the newly created Image Target and scale it down to match the width of the target.
    • Optional: Remove the Update()method from the Cube.cs script to stop the cube from rotating.
  6. As a result of the changes, the cube displayed in the Unity scene will now be rendered on top of the Vuforia Astronaut Image Target.

Android Specific Steps

After following the steps in the general Unity guide (UaaL Android guide ), Vuforia Engine is bundled as a library for Android to import. We recommend setting the Configuration settings in Player -> Other Settings to ARM64 and IL2CPP.

In Android Studio, the following steps can now be added:

  1. Vuforia Engine (as well as the Unity 2019.3 beta versions) require the minSdkVersion to be set to 19 in the android – defaultConfig section of the build.gradle (Module: app).

  1. Click “Sync now”:

  1. Add the gradle structure path for the UnityLibrary under allprojects/repositories/. See also Unity’s documentation on the gradle setup.
allprojects
{
  repositories
  {
    flatDir
    {
      dirs "$ {project(':unityLibrary').projectDir} /libs"
    }
  }
}
  • Now sync the gradle project a last time, it should build and run fine now: 

iOS specific steps

After following the steps in the general Unity guide (UaaL iOS guide), apply the following steps in Xcode:

  • Add Vuforia.framework
    • In the NativeiOSApp project, under General / Embedded Binaries, press +
    • Click on Add Other…
    • Select the iosBuild/Frameworks/com.ptc.vuforia.engine/Vuforia/Plugins/iOS/Vuforia.framework and Open.
    • Delete (press -) on the linked Frameworks and Libraries on Vuforia.framework.

Add Camera usage description

  1. Even if the camera usage description was set in Unity, it needs to be added to the NativeiOSApp project:
  2. From the tabs, select Info.
  3. At Custom iOS Target Properties, Hover over any of the currently applied properties and press +
  4. From the list choose Privacy - Camera Usage Description.
  5. Set it to something like Required for augmented reality support.

Move the Vuforia folder

  1. In order to be able to load Vuforia target databases at runtime, the “Vuforia” folder from the Unity-iPhone project needs to be moved to the NativeiOSApp project.
  2. After it has been moved or copied, set its Target Membership to “NativeiOSApp”:

Can this page be better?
Share your feedback via our issue tracker