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. By following this walk-through, you'll learn how to use a GameObject to base your real-world scene upon.
- 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 Maps Unity SDK Demo, and imported it into Unity.
Step 3: Save the scene
Click File > Save Scenes.
Name your scene Any Location.
Step 4: Create an empty GameObject
This GameObject will serve as the underlying GameObject for your MapsService script component. The Maps Unity SDK 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 5: Add the MapsService script component
The MapsService script component is the entry point into the Maps Unity SDK Demo. With the Map Base GameObject selected in the Hierarchy:
In the Inspector, click Add Component.
In the Add Component selector dialog, select Scripts > GoogleMaps > Maps Service. The Maps Service (Script) component appears beneath the Transform component.
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, select Scripts > Basic Example.
In the Lat Lng field of the Basic Example component, enter "40.748, -73.988". This is a coordinate in the center of Manhattan, the location supported by the demo.
Save the scene by clicking File > Save Scenes.
Step 7: Run the scene
- Click the Play button. A scene that contains the center of Manhattan appears in both the Scene pane, and in the Game pane.