Vuforia Engine and AR Foundation

Vuforia Engine can now be used alongside AR Foundation in the same scene regardless of which platform you started developing with. Utilize both platforms to enhance your AR project by simply adding either to your project via Unity’s Package Manager.

Overview and Prerequisites

It is possible to add Vuforia Engine targets to an existing AR Foundation project, and similarly, adding AR Foundation capabilities to Unity project already using Vuforia Engine. This enables you to utilize, for example, vertical planes or environment probes from AR Foundation in your Vuforia scene or using Model Targets and Area Targets in your AR Foundation scene. 

Requirements

  • Requires a Development or Pro license
  • Vuforia Engine 9.5 and later.
  • AR Foundation 4.0 and later. 
  • ARKit and/or ARCore.

UWP Tablets, HoloLens, and Magic Leap devices are not supported for this cross-platform integration.

All Vuforia Engine features are supported and AR Foundation features are supported with the exception of content scaling. Both platforms draw on the same coordinate system meaning that anchors and plane detection works interchangeably with detecting and positioning AR content in the environment. 

NOTE: Combining Vuforia Engine and ARFoundation in the same scene does add performance overhead and latency. While this is barely noticeable on iOS devices; on Android, this will result in higher latency and less stable tracking of Vuforia targets. 
In any case, we recommend using Vuforia Engine and ARFoundation together only if capabilities of both are needed. For best performance and lowest latency, use Vuforia Engine without ARFoundation.

Adding Vuforia or AR Foundation

When Vuforia Engine targets are added to an existing Unity scene, Vuforia will automatically detect at runtime if AR Foundation is already used. If a scene already contains ARFoundation game objects, the Vuforia AR Camera GameObject does not need to be added in addition. 

Unity setup

Make sure that your Unity project is correctly targeting the platform you wish to build to. Also, include the platform provider according to the chosen platform.

  • Install and enable the platform-specific XR Plugin.
    • Go to Window -> Package Manager and install the XR plugin.
    • In Project Settings select XR Plug-in Management -> <platform> and enable the Plug-in Providers (I.e., ARKit, ARCore).
  • Add a license key in the Vuforia Configuration to use of the FileDriver.

Add Vuforia Engine to an AR Foundation scene

  1. Add Vuforia Engine to the project by using the Package Manager. Firstly, download and import the retrieval script as a custom package from Vuforia’s Developer Portal. The Vuforia Engine package is thereafter available in the Package Manager. For more information on adding Vuforia Engine, please see Vuforia Engine Package Hosting for Unity

NOTE: The VuforiaBehaviour component is automatically added onto the AR Foundation’s AR Camera GameObject at runtime as soon as Vuforia Engine targets are added to an ARFoundation scene. The World Center Mode will be automatically set to Device

Add AR Foundation to a Vuforia Engine scene

The process for adding AR Foundation to an existing Vuforia enabled project is similar. 

  1. Open the Package Manager window and search the list in the Unity Registry for the AR Foundation package.
  2. Click it and press the install button. 

Building an AR Scene

In order to have Vuforia Engine and AR Foundation working side by side, components from both platforms are required in the scene. You should also use only one AR Camera GameObject – namely the AR Camera from AR Foundation. 

NOTE: In order to use Vuforia Engine targets in an ARFoundation scene, at least one Vuforia target needs to be present in the scene at build time. Only adding targets at runtime through scripting is not supported.

The following steps demonstrate how to build an example scene combining Vuforia Engine image targets and ARFoundation’s environment probes:

  1. Start by replacing the default camera in the scene with the AR Foundation AR Session Origin GameObject. Right-click in the Hierarchy and select XR -> AR Session Origin.
    1. The AR Camera is child of this GameObject
  2. Add from the same menu the AR Session GameObject.
  3. Add a Vuforia target by right-clicking in the Hierarchy and selecting Vuforia Engine -> … Add any desired content, for example, a sphere on the Vuforia target. 

  1. Add the AR Environment Probe Manager component to the AR Session Origin GameObject.

  1. Create a new material and set its Metallic and smoothness properties to 1 (one). Ensure also that Specular Highlights and Reflections are enabled.
  2. Assign the material e.g. to the sphere that is used as augmentation for the Vuforia image target. This will display reflections from the environment probe on the target’s augmentation.

  1. Continue to set up the Build Settings as shown in our Getting Started with Unity guide and build the project to your device for testing. 

Anchors

Vuforia relies on ARFoundation to create Anchors when combined in the same scene. Therefore, the ARAnchorManager component is required on the AR Session Origin GameObject. If there is no ARAnchorManager, Vuforia will automatically create one.

AR Session

ARFoundation’s ARSession controls the lifecycle of the AR experience and resetting it would reset the data that Vuforia relies on, such as Anchor positions. This would for example occur when a scene is unloaded and the VuforiaBehaviour is destroyed.  

Vuforia Ground Plane

In order to use Vuforia Engine’s Ground Plane feature together with ARFoundation, it is necessary to add the following AR Foundation components to the AR Session Origin GameObject.

  • ARRaycastManager 
  • ARPlaneManager