You can subscribe to events to get notified about state changes to layers, elevation sources, and the view. The following events, for example, can be used to help you determine if there is a problem with your scene or to make user interface updates.
ArcGISViewStateChangedEventArcGISLayerViewStateChangedEventArcGISElevationSourceViewStateChangedEventArcGISDrawStatusChangedEvent
These events will return the current state of the content in the view through ArcGISViewState, ArcGISLayerViewState, ArcGISElevationSourceViewState, and ArcgisDrawStatus objects. These state objects contain a combined status to indicate, for example, that a specific layer is not visible or has a warning. Additional information from some of these objects can be obtained by calling GetMessage() when the status is an error or a warning.
ArcGIS View State Logging Component
To subscribe to the events and print status messages (for example, layer view status messages) to the Console:
You can attach the ArcGIS View State Logging to the ArcGIS Map game object by taking the following steps.
- Click the ArcGIS Map game object in the Hierarchy window.
- In the Inspector window, click the Add Component button.
- Search for ArcGIS View State Logging and select it to attach the component.
To write your own script with the C# API, use the events listed above to subscribe to changes in the view, layers, elevation sources, and drawing states.
The DisplayDrawStatus sample demonstrates how to subscribe to the ArcGISDrawStatusChangedEvent, which triggers when there are changes to the drawing state.
This sample uses the DisplayDrawStatusCreator class to show a loading spinner while layers in the map are drawing. The class can be found in:
Assets/Samples/ArcGIS Maps SDK for Unity/[version]/Sample Content/Scenes/Scripts/DisplayDrawStatus
You can find the sample code to subscribe to other events and log the state to the Console in the ArcGISViewStateLoggingComponent.cs file. The sample script file can be found in:
Assets/Samples/ArcGIS Maps SDK for Unity/[version]/Sample Content/Components
If you don’t have the folder in your project, import sample assets.