Several game objects and components that come with the ArcGIS Maps SDK for Unity plugin are essential for rendering and interacting with your ArcGIS scene.
A Camera component is used to set the data loading point for an ArcGIS scene. For the Camera to work, the Camera game object must have the ArcGIS Camera component and be a child of an ArcGIS Map game object.
You need to attach an ArcGIS Camera component to a game object with a Camera component to load tiles and scene nodes for the ArcGIS Map. When the camera moves, ArcGIS Map will set the view that will determine what tiles and scene nodes are streamed and rendered.
Two settings for the play mode are enabled by default on the ArcGIS Camera component:
- Update Clipping Planes: This option adjusts the near and far planes of the Unity camera component every frame. The near and far planes are adjusted based on the altitude of the camera game object in geographic space; the higher the game object, the further the camera will render.
- Use Camera Viewport Properties: This option allows you to manually adjust the size of the viewport of the ArcGIS Camera component when this option is disabled. This allows you to have more control over what is rendered during a frame update. When this option is enabled, the ArcGIS Camera component will use the Unity camera component's viewport settings.
An additional setting is used to control data quality:
- Quality Scaling Factor: This option allows you to control the quality of the GIS content being rendered. A higher number indicates higher quality and a higher impact on performance. The default number is
An ArcGIS Location component must be attached to the ArcGIS Camera component on the same game object to place it with geographic coordinates. This allows the ArcGIS Camera and its game object to be accurately positioned in the ArcGIS scene. For more information about the ArcGIS Location component, see the location component topic.
The ArcGIS Location component transforms Unity coordinates into GIS coordinates and defines the position. The ArcGIS Camera defines the tilt and heading of the point from which the scene is observed.
- X (Longitude) : Specifies the east–west position of a point on the Earth's surface. A projected position value for projected coordinate systems or a longitude value for geographic coordinate systems.
- Y (Latitude) : Specifies the north–south position of a point on the Earth's surface. A projected position value for projected coordinate systems or a latitude value for geographic coordinate systems.
- Z (Altitude) : The vertical distance of the camera above the terrain.
- Spatial Reference WKID : The spatial reference of the X, Y and Z values in Well-Known ID (WKID).
- Heading: Provides the ability to either get or set the map view rotation value. This is also known as yaw or azimuth. It represents the number of degrees by which the map's data will be rotated, measured counterclockwise from the north. To rotate clockwise, use a negative value.
- Pitch: Provides the ability to either get or set a map view's pitch. Pitch is the equivalent of moving a plane's nose up or down (rotating along the axis that passes through the plane's wings). Positive values, looking forward, are above the horizon (pointing upward) and negative values are below the horizon (pointing downward).
- Roll: Provides the ability to either get or set a map view's roll. Roll is the equivalent of tilting a plane's wings up or down (rotating along the axis that passes through the center of the plane from front to back). A zero value is perfectly horizontal. Positive values will tilt the left side upward (or the right side downward). Negative values do the opposite.
To set up an ArcGIS Camera:
You can create an ArcGIS Camera from the Map Creator Camera tab.
- Click on the Camera tab.
- Fill in the values for the camera position and rotation.
- Click on the Create Camera button.
When you create a camera with this feature, it will be parented to the ArcGIS Map in the Hierarchy window. If you have a camera in the scene that is tagged as MainCamera, it will be parented to the ArcGIS Map and ArcGIS Camera and ArcGIS Location components will be added to it.
If you find a better camera angle while you navigate around in the Editor mode, click Align with View to update the initial camera position for Play mode.
If you want to control the camera during Play mode, attach an ArcGIS Camera Controller component to the camera game object. The ArcGIS Camera Controller component can be found in the Assets/Samples/ArcGIS Maps SDK for Unity/[version]/Sample Content/Components folder:
- Click ArcGISCamera in the Hierarchy window. If it is not visible, expand ArcGISMap.
- In the Inspector window, click the Add Component button.
- Search for ArcGIS Camera Controller component and attach it to the camera.
The ArcGIS Camera must be a child of ArcGIS Map.
- Create a camera under
- Click on the Add Component button in the Inspector window.
- Search for ArcGIS Camera component and attach it to the camera.
- Click on the Add Component button again.
- Search for ArcGIS Location and attach it to the camera.
If you find a better camera angle while you navigating in Editor mode, use the Align with View button found in the Map Creator Camera tab to align the ArcGIS Camera game object with the Scene view and update the starting camera position for Play mode.
For the camera control in the Play mode, attach a camera controller to the camera you created. If you want to use the ArcGIS Camera Controller in the Asset/ArcGISMapsSDK/Samples/Components folder on your camera:
- Click on the camera in the Hierarchy window.
- In the Inspector window, click on the Add Component button.
- Search for ArcGIS Camera Controller component and attach it to the camera.
ArcGISCamera and an
ArcGISLocation to the camera. You can also attach an
ArcGISRebase if your app needs to cover large areas. Attach a camera controller if you want to move the ArcGIS Camera and load different LODs according to the camera position.
ArcGISLocation, you can programmatically set the position by using an
ArcGISPoint to set the camera position and an
ArcGISRotation to set the pitch, roll and heading.
You can find sample code that demonstrates how to place and set up a camera in the SampleAPIMapCreator.cs file. The sample script file is in:
Assets/Samples/ArcGIS Maps SDK for Unity/[version]/Sample Content/Scenes/Scripts/APISample
It is not a requirement to attach an ArcGIS Camera component to your active camera. In some cases, you may want to use an ArcGIS Camera as a fixed loading point to only bring in a set LOD (level of detail) into your scene. You can attach the ArcGIS Camera component and an ArcGIS Location component to an empty game object, then set the position of the game object through the ArcGIS Location component.
ArcGIS Maps SDK for Unity comes with a sample ArcGIS Camera Controller component that you can use in your ArcGIS scenes. This component correctly wraps and moves around the Earth in both global and local scenes, and it is controlled by using the WASD keys and mouse during runtime. This component is meant to be a sample that demonstrates how you can move the camera. If you want to change how the camera moves, update this script or write your own script, and attach it to your camera.
The ArcGIS Rebase component is responsible for periodically updating the world's origin position as the camera moves around. Unity uses 32-bit floating point precision, which isn't precise enough to cover the whole world.
To enable the same behavior during Editor mode, enable the Rebase In Scene View option in the ArcGIS Map component.
When Editor mode is enabled, the ArcGIS Camera loads data according to its position and displays it in the Scene view. It will load better LODs for areas closer to the view and lower LODs for the areas that are further away.
Whether you create an ArcGIS Map with the Map Creator UI or by manually adding components, the Data Fetch Using Scene Camera is enabled by default and the Rebase In Scene View option is disabled in the ArcGIS Map component.
The Data Fetch Using Scene Camera option allows the loading of LOD data according to the Scene View camera instead of ArcGIS Camera. When you have multiple cameras in your scene and want to use the ArcGIS Camera as a fixed data loading point in the Editor mode, disable the option to not load different LODs according to the Scene View camera position.
When the Rebase In Scene View option is enabled, the Origin position will be periodically updated while you navigate the scene. This option is useful when you explore larger areas during Editor mode.