You'll create a scene in Unity that loads real world features from a particular location—in this case around the Statue of Liberty.
You'll see how to use a GameObject as an anchor for your real-world scene; and also, how to provide new coordinates—to generate another real-world scene.
- You already have Unity version 2018.4 or later, and you currently have it running in front of you.
Step 1: Create a new project
- In Unity, click File > New Project....
- Name your project quickstart, and then click Create project.
The Unity IDE appears with a default scene selected in the Hierarchy pane.
Step 2: Import the SDK
Follow the Install the Maps SDK for Unity SDK procedure. When you're done, you'll have created an API key, downloaded the SDK and imported it into Unity.
Step 3: Create an empty GameObject
This GameObject will serve as the underlying GameObject for your MapsService script component. The Maps SDK for Unity will then add generated geographic feature GameObjects as children of this GameObject.
In the Hierarchy pane, click the Create drop-down, and then select Create Empty.
Change the name of the new GameObject to Map Base.
Step 4: Add the MapsService script component
The MapsService script component is the entry point into the Maps SDK for Unity. With the Map Base GameObject selected in the Hierarchy:
In the Inspector, click Add Component.
In the Add Component selector dialog, search for and select Maps Service. The Maps Service (Script) component appears beneath the Transform component.
In the Maps Service component, paste your API key into the API Key field.
Step 5: Add the Basic Example script component
This script sets the coordinates for the real-world location to be loaded into the scene, gets the MapService component, then uses it to initialize the floating origin, and finally loads the map with default options.
With the Map Base GameObject selected in the Hierarchy; in the Inspector, click Add Component.
In the Add Component selector dialog, search for and select Basic Example.
Save the scene by clicking File > Save.
Step 6: Run the scene
- Click the Play button. A scene that contains the Statue of Liberty appears in both the Scene pane, and in the Game pane.