Skip to main content

Setting Up the Niantic SDK for Unity

To set up the SDK, you will download and install Unity, then install the ARDK Unity packages and set up Unity for the platform your AR experience will run on. After that, you will authenticate Lightship in Unity with your API key, perform any additional setup your platform device requires, and set up the basic requirements for an AR scene in Unity.

Beta Content

The Lightship Magic Leap 2 integration is in beta, so some features may not work as expected.

Download and Install Unity

Download Unity. We support Unity 2022 LTS (with 2022.3.37f1) and 2021 LTS (with 2021.3.37f1).

Attention!

Unity 2022 LTS users will need to manually upgrade Visual Scripting from 1.9.0 to 1.9.1 or higher via the Package Manager to avoid a SessionStateChangedEventUnit error.

Create a Project and Install ARDK

Create a Project and Install ARDK

  1. Create a new Unity project with the Universal 3D (Core) template.
  2. In your Unity project, open the Window top menu, then select Package Manager.
  3. From the plus menu on the Package Manager tab, select Add package from git URL....

    Package Manager menu

  4. Enter https://github.com/niantic-lightship/ardk-upm.git.
    1. If prompted, click Yes to activate the new Input System Package for ARFoundation 5.0. This may require a restart of the Unity Editor.
  5. To add the SharedAR package, repeat these steps using the following URL instead: https://github.com/niantic-lightship/sharedar-upm.git.

To use a specific ARDK version, download its .tgz from our release pages (ardk-upm, sharedar-upm). Then, follow the installation instructions above and select "Add package from tarball" instead of the Git URL.

Create a Lightship Account and Add API Key

  1. Open the Lightship top menu, then select Settings to open the Lightship Settings menu. Click on Get API Key under Credentials. This should open the lightship.dev website in a browser window.
  2. Create a new Lightship account if you need to, then log in.
  3. Open the Projects page, then select an existing project or create a new one by clicking New Project.
  4. In your project's Overview, copy the API Key by clicking the copy icon next to it.
  5. Return to the Lightship Settings window in Unity and paste your API Key into the API Key field.

Activate the XR Loader for Your Mobile Platform

caution

In Unity version 2022.3.10f1 or newer, you might see a benign error in the console after following these steps.

  1. Open the Lightship top menu, then select XR Plug-in Management.
  2. In the XR Plug-in Management menu, select the Android tab, then check the box labeled Niantic Lightship SDK + Google ARCore.

Configure the Build Platform

  1. Open the Build Settings window by selecting File > Build Settings.
  2. Select iOS or Android, then click Switch Platform. After the progress bar finishes, click Player Settings. Select your platform from the tabs, scroll down to Other Settings, and change the following settings:
  • Rendering - Uncheck Auto Graphics API. If Vulkan appears in the Graphics API list, remove it.
  • Identification - Set the Minimum API Level to Android 7.0 'Nougat' (API Level 24) or higher.
  • Configuration - Set the Scripting Backend to IL2CPP, then enable both ARMv7 and ARM64.
Attention!

If you are using Unity 2022.3.15f1 or older, building to Android requires a custom Gradle installation.

Click here to reveal the Gradle installation instructions
  1. Download and install Gradle 6.7.1 from the Gradle Releases page.
  2. Replace the default Gradle install in Unity:
  3. In Unity, open Preferences > External Tools > Android.
  4. Uncheck the box labeled Gradle installed with Unity (recommended), then replace the path with your local installation of Gradle 6.7.1.
Custom Gradle Build Settings
tip

If you are building through the command line, you can customize the Gradle path by setting AndroidExternalToolsSettings.gradlePath in your Unity build script.

  1. Set your Build Target to Android.

Next Steps

Setting Up a Basic AR Scene

To get started creating your own AR project, begin by creating an empty AR scene:

  1. Create a new Basic scene:
    1. From the main menu, choose File > New Scene.
    2. Select Basic (Built-in) and click Create.
  2. Right-click on the Main Camera and select Delete.
  3. Add an ARSession and XROrigin to your new scene
    1. Select the new scene in the Hierarchy.
    2. From the main menu, select Game Object > XR > AR Session.
    3. Repeat to add an XR Origin (Mobile AR).
  4. Save the scene using File > Save.
tip

If you choose Save As Scene Template, you can select this scene in the New Scene dialog next time.

Further Reading

From here, proceed to the Sample Projects page to try out the features or to the How-To page to experiment with a guided tutorial. If you instead have a previous ARDK project you would like to convert to ARDK 3, see our Migration Guide.