Skip to main content
Version: 3.1

How to Place Content in Real-World Locations Using Location AR

This how-to covers:

  • Importing a real-world location from the Geospatial Browser (GSB) into Unity;
  • Placing content in a real-world location;
  • Testing placed content, either using a mockup or on location.

Prerequisites

  1. You will need a Unity project with ARDK installed and a set-up basic AR scene. For more information, see Setup ARDK 3 and Setting up an AR Scene.
  2. You will need a valid API Key.

Adding a Real-World Location to Unity

To add an AR location to Unity:

  1. Go to the Geospatial Browser and find the location you want to build content for. The data will download as a .zip file; do not unzip it. For more information on downloading location data, see Downloading Meshes.
  2. Drag and drop the downloaded zip file into the Assets directory in the Project window. Once the import process completes, it will create two assets, a Mesh .prefab file and a Manifest .asset file.
  3. Turn on Persistent Anchors in Lightship Settings:
    1. Click the Lightship top menu, then select Settings.
    2. In the Inspector window, check the Enabled box next to Persistent Anchors.
    Unity menu with 'Enable Persistent Anchors' checked
  4. Add an AR Location Manager component to the XROrigin:
    1. Select the XROrigin in the Hierarchy, then, in the Inspector window, click Add Component and search for ARLocationManager.
    2. In the ARLocationManager Component, click Add AR Location to create a new ARLocation.
  5. In the Hierarchy, select the ARLocation to show its Component in the Inspector. Drag and drop the Manifest from the Assets directory to the AR Location Manifest field in the Component.
    1. This will change the name of the manifest; rename it back to ARLocation.

Adding Real-World AR Content

When adding your AR content, remember the following:

  1. Add your AR content as a child of the manifest (ARLocation). For example, to add a Cube to a location:
    1. In the Hierarchy, right-click the ARLocation, then mouse over 3D Object and select Cube.
    2. In the Inspector, set the cube's Scale to 0.5 and its position to 0,0,2.
  2. Make sure to enable auto-tracking:
    1. In the Hierarchy, select the XROrigin, then, in the Inspector window, check the Auto-Track box in the ARLocationManager Component.

Testing Real-World AR Content

The most accurate way to test real-world AR content is by building your Unity app to a device and physically visiting the location to test it out. Because this is not always possible, Lightship also provides Mock Mode, giving developers the ability to create a mock localization of the scene that allows non-AR GameObjects to run through their Behaviors.

note

Other AR Subsystems (including ARSession, Camera, Meshing, etc) will not work in Mock Mode. It is strictly for testing localizations.

note

To enter Mock Mode and test AR content:

  1. If you have enabled Playback, disable it.
  2. Enter Play Mode. Lightship will add a Mock Camera asset to your scene (as a child of Main Camera) that allows movement with the WASD keys and zooming with the scroll wheel. This will also create a mock localization that allows GameObjects to run through their Behaviours.
tip

You can also test localizations using Playback. See How to Setup Playback.

Swapping Locations Using Code

Using a script to control content localization instead of the Auto-Track feature allows applications to dynamically swap which location is in use.

To localize dynamically using a script:

  1. Grab a reference to the ARLocationManager and each ARLocation you intend to use.
  2. Call SetARLocations(currentLocation) on the ARLocationManager to select the localization for that location to target.
  3. Call StartTracking() on the ARLocationManager to localize and track the selected location.
  4. To switch locations:
    1. Call StopTracking on the ARLocationManager.
    2. Call SetARLocations(newLocation) on the ARLocationManager again with your new location.
    3. Call StartTracking() on the ARLocationManager again to restart tracking.

More Information