You'll create a real-world scene in Unity, that at run-time, contains the geographic features associated with a particular set of geographic coordinates (which features the Statue of Liberty).
You'll see how to use a GameObject to base your real-world scene upon; 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 Getting Started procedure. When you're done, you'll have downloaded the SDK, imported it into Unity, and created an API key so you can make API calls.
Step 3: Create an empty GameObject
This GameObject will serve as the underlying GameObject for your MapsService script component. The Maps SDK for Unity Demo 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 Demo. 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.
Step 5: Set the API key value
The Maps Service script exposes the Api Key data member publicly, which means you can set its value in the Inspector.
- In the Inspector, paste the value of your API key into the Api Key field.
Step 6: 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 7: 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.