This page describes how to enable ARCore functionality in your Unity projects. To do this, you need to:
- Get the ARCore Extensions package
- Create a new project and import the ARCore Extensions package
- Configure your app to be AR Required or AR Optional
- Make sure your app complies with ARCore's User Privacy Requirements
Get the ARCore Extensions package
The ARCore Extensions for AR Foundation package is available from GitHub:
Download the latest
arcore-unity-extensions-*.tgzfrom the GitHub releases page.
Extract the downloaded archive to a local folder. Make sure it's a location that is convenient -- after you install the package into your project, you won't be able change the folder's location or contents without first uninstalling the package. You may reinstall the package after changing the folder location.
Create a new project and install the ARCore Extensions package
Open Unity and create a new 3D project.
To import the ARCore Extensions package downloaded from GitHub into your project, follow these steps:
Open the Package Manager (choose Window > Package Manager).
In the top left corner of the Package Manager, click the + (plus) button. Choose Add package from disk…
Locate the local folder where you unzipped the archive, and select the
package.jsonfile, then click Open.
Wait a moment while Unity installs this and dependent packages into your project.
Configure your app to be AR Required or AR Optional
An app that supports AR features can be configured in two ways: AR Required and AR Optional. If you need help deciding which one to choose, see Publish AR Apps in the Google Play Store.
Make an app AR required
The Google Play Store makes AR Required apps available only on devices that support ARCore.
When users install an AR Required app, the Google Play Store automatically installs Google Play Services for AR. However, your app must still perform additional runtime checks in case Google Play Services for AR must be updated or has been manually uninstalled.
To make an app AR Required:
Create an instance.
Make sure that the Edit > Project Settings > XR > ARCore > Requirement > Required menu item is checked as shown below. It is checked by default.
Your app will automatically perform runtime checks to make sure that the device supports ARCore and has Google Play Services for AR installed. If the APK is not installed (possibly because it was removed by the user) or the version is too old, your app will prompt the user to install or update. If the install or update fails (possibly due to a network failure),
ARSession.ARSessionStatewill return an error, and your app should handle the error and quit.
Make an app AR Optional
An AR Optional app has optional AR features, which are activated only on devices that has Google Play Services for AR installed.
AR Optional apps can be installed and run on devices that don't support ARCore.
When users install an AR Optional app, the Google Play Store will not automatically install Google Play Services for AR with the app.
To make an app AR Optional:
Check the Edit > Project Settings > XR > ARCore > Requirement > Optional menu item.
Perform runtime checks
If your app is AR Optional, it should check
launch. This checks whether the device supports ARCore and, if so, whether Google
Play Services for AR is installed.
Your app should handle these conditions:
|Device does not support ARCore.||Hides AR-related functionality.|
|Device supports ARCore, but Google Play Services is either not installed or out of date.||Prompts the user to install or update by calling
|Device supports ARCore and Google Play Services for AR is installed and up to date.||Creates an ARCore
User Privacy Requirements
Make sure your app complies with ARCore's User Privacy Requirements.
Read the code in the sample app and ARCore for Unity API reference.