Get started with Geospatial Creator for Unity

1. Before you begin

Geospatial Creator, powered by ARCore and Google Maps Platform, lets you create augmented-reality (AR) experiences in the Unity editor. It uses Google's Photorealistic 3D Tiles API to preview what the experience looks like in the real world without the need to physically visit that location.

In this codelab, you get started with the Geospatial Creator. You get the quickstart Unity project set up and learn how to operate the editor. After that, you import an asset into the scene and position it into the digital twin of the world. You add an animation to the asset to bring it to life. Finally, you view the content on your device in AR.

A tiger in AR

Prerequisites

  • Basic knowledge of AR

What you'll learn

  • How to set up the ARCore Geospatial Creator project in Unity.
  • How to navigate the Scene view.
  • How to place a 3D asset within the Scene view.
  • How to add a simple behavior to the asset.
  • How to run the AR experience on your device.

What you'll need

2. Set up your development environment

To retrieve Photorealistic 3D Tiles data from Google Cloud, you need to set up authorization.

Set up a Google Cloud project

  1. Create a project in Google Cloud console.Create a Google Cloud project
  2. In the Project name text box, enter an appropriate name, such as ARCore Geospatial API project, and then choose any location.
  3. Click Create.
  4. In the Google Cloud console on the project-selector page, click Create Project.

Enable the 3D Tiles API

To enable the 3D Tiles API, click the following button, and then select Enable:

Enable the ARCore API

To enable the ARCore API, click the following button, and then select Enable:

Create an API key for your project

  1. In Google Cloud console under APIs & services, select Credentials.
  2. At the top of the page, click Create Credentials, and then select API Key.
  3. Note the key because you need it for the next steps.

Set up the software

To get started with Geospatial Editor, follow these steps:

  1. In Unity Hub, create a 3D project with Unity version 2021.3.17f1 or higher.
  2. Click Window > Package Manager, and then follow these steps to add the necessary packages:
    1. Click + > Add package from git URL > https://github.com/google-ar/arcore-unity-extensions.git.
    2. Click Samples, and then import the geospatial sample.
    3. , and then click + > Add package from tarball > com.cesium.unity-1.0.0.tgz.
  3. If it isn't installed already, follow these steps to install Shader Graph:
    1. Click In Project > Unity Registry.
    2. Install Shader Graph.

Package manager window

Set up the sample scene with ARCore objects

  1. In the Project panel, click Assets > Samples > ARCore Extensions > 1.37.0 > Geospatial Sample > Scenes > Geospatial.
  2. Click Layers, and then disable the UI layer.
  3. Click Edit > Project Settings > XR Plug-in Management > ARCore Extensions.
  4. Configure an API key authorization strategy for your target platform.
  5. Enable the Geospatial and Geospatial Creator optional features.
  6. In the Hierarchy panel, click + > XR > Geospatial Creator Origin.
  7. In the Hierarchy panel, select AR Geospatial Creator Origin.
  8. In the Inspector panel under Geospatial Creator Origin, click Add Cesium Georeference Component.
  9. In the Google Maps Tile API Key text box, insert the API key, and then press Enter (or return on macOS).

Tiles in Scene view

3. Navigate the Unity Scene view

In this step, you view the 3D representation of the area around you.

Change the location of the 3D view

To change the location of the 3D Photorealistic Tiles preview to an area near you, follow these steps:

  1. In the Hierarchy panel, select the AR Geospatial Creator Origin game object.
  2. In the Inspector panel, follow these steps to change the Latitude and Longitude values to a location near you:
    1. Use Google Maps to find a location near you.
    2. Right-click the map, and then select the provided coordinates to copy them to your clipboard.
      Google mapsAfter you modify the values, the 3D representation of the world in the Scene window changes:
      Updated coordinates

Control the viewport camera

To find a location near you where you want to put your Geospatially anchored content, follow these steps:

  1. Use the up and down arrow keys to move the camera forward and backward.
  2. Use the left and right arrow keys to pan the view.
  3. While moving, press and hold Shift to move faster.
  4. If you get lost, in the Hierarchy panel, select the AR Geospatial Creator Origin object, and then press F to recenter the view on it.

4. Import and place a 3D asset

After you decide on a location near you, you need to import an asset that appears in your AR experience, and is anchored near the location that you selected.

Import a 3D asset

To help you with this codelab, we prepared a sample asset for you to use in your project.

To import the sample asset, follow these steps:

  1. .
  2. Extract the zip archive.
  3. Click Assets > Import new asset. The four assets are imported into your project.
  4. In the Project panel, drag the Tiger model asset into the Scene panel.

Resize and reposition the asset

To put your asset in the right place, follow these steps:

  1. In the Hierarchy panel, ensure that the Tiger model asset is selected.
  2. In the Scene view, ensure that the Scale tool is enabled, and then drag the white cube to adjust the size of the asset to your preference.
    Scale tool
  3. In the Scene view, ensure that the Move tool is enabled, and then select the red, blue, or green controls, and drag your mouse to reposition the asset. Each colored control locks a certain dimension and lets you move an object along that axis.
    Move tool

Geospatially anchor the asset

To anchor your content to the real world, follow these steps:

  1. In the Hierarchy panel, ensure that the Tiger model asset is selected.
  2. In the Inspector panel, press Add Component to add a AR Geospatial Creator Anchor.

5. Bring your asset to life

The Unity editor lets you program delightful AR experiences with the power of the Unity ecosystem.

To use one of the animations provided in the starter project to animate the tiger on a loop, follow these steps:

  1. In the Hierarchy panel, select the Tiger model.
  2. Click Add Component to add an animator.
  3. In the Animator section, select a Controller, and then use the provided Tiger idle animation controller asset.

Tiger animation

6. View the asset in AR

Finally, you view the asset in AR on your ARCore-supported Android or iOS device.

Run the app on your device

  1. Click File > Build Settings, and then select either the Android or iOS build platforms.
  2. Click Switch platform.
  3. Follow additional steps to configure player settings.
  4. Ensure that your development device is connected and configured for development.
  5. Click Build and run.

7. Conclusion

Congratulations! You learned how to use Geospatial Creator in Unity to create a Geospatial AR experience.

Learn more