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.
- Unity 2019.4 and later is supported
- 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.
Add Vuforia Engine to an AR Foundation scene
- 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.
- Open the Package Manager window and search the list in the Unity Registry for the AR Foundation package.
- 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:
- 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.
- The AR Camera is child of this GameObject
- Add from the same menu the AR Session GameObject.
- 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.
- Add the AR Environment Probe Manager component to the AR Session Origin GameObject.
- Create a new material and set its Metallic and smoothness properties to 1 (one). Ensure also that Specular Highlights and Reflections are enabled.
- 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.
- 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.
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.
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.