Enable ARCore

This page describes how to enable ARCore functionality in your Unity projects. To do this, you need to:

  1. Import the ARCore SDK for Unity
  2. Configure your app to be AR Required or AR Optional
  3. Make sure your app complies with ARCore's User Privacy Requirements

Using Google Play Services for AR to enable ARCore functionality

ARCore SDKs make AR features available on ARCore supported devices that have Google Play Services for AR installed. Users can install and update Google Play Services for AR from the Google Play Store.

Import the ARCore SDK for Unity

Download the ARCore SDK for Unity and import it into your project by clicking the menu Assets > Import package > Custom Package. (Unity 2019 only: To fix the compilation errors, use Window > Package Manager to install the Multiplayer HLAPI and XR Legacy Input Helpers packages.)

In Unity's Project window, you should see both the SDK files and the HelloAR sample app in Assets/GoogleARCore/Examples/HelloAR/.

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.

AR Required

To be usable, an AR Required app requires an ARCore Supported Device that has Google Play Services for AR installed on it.

  • 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.

For more information, see Publishing AR Apps in the Google Play Store.

To make an app AR Required, make sure the Edit > Project Settings > ARCore > ARCore 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), Session.Status will return an error, and your app should handle the error and quit.

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, uncheck the Edit > Project Settings > ARCore > ARCore Required menu item.

Perform runtime checks

When launched, your app should call Session.CheckApkAvailability() to check whether the device supports ARCore and, if so, whether Google Play Services for AR is installed.

Your app should handle these conditions:

Condition Action
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 Session.RequestApkInstallation().
Device supports ARCore and Google Play Services for AR is installed and up to date. Creates an ARCore Session and starts using ARCore.

User Privacy Requirements

Make sure your app complies with ARCore's User Privacy Requirements.

Next Steps

Read the code in the sample app and ARCore for Unity API reference.

傳送您對下列選項的寶貴意見...

這個網頁