Vuforia Engine can 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 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. AR Foundation support allows you to utilize vertical planes or environment probes in your Vuforia scene or using Model Targets and Area Targets in your AR Foundation scene.
- Please refer to Supported Versions on the supported Unity Editor versions.
- AR Foundation 4.0 or later.
- ARKit and/or ARCore supported device.
Available with the BASIC and PREMIUM plan
UWP Tablets, HoloLens, and Magic Leap devices are not supported for this cross-platform integration.
All Vuforia Engine features are supported and all 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 AR Foundation 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 AR Foundation together only if capabilities of both are needed. For best performance and lowest latency, use Vuforia Engine without AR Foundation.
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 the ARFoundation game objects, the Vuforia AR Camera GameObject does not need to be added to the scene.
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.
- Add the Vuforia Engine SDK to the project by using the Package Manager. Firstly, download and import the SDKfrom Vuforia’s Developer Portal. 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 ARFoundation.
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 as a child to 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 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 AR Foundation 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.