0

I want to add the custom data to the Mapbox in Unity.

Unity version: 2020.3.36f1
Scripting Runtime Version: vsCode
Api Compatibility Level: NET4.0 Mapbox SDK version: 2.0.0 The platform I am building to: Android, IOS.
I want to change the colors of the buildings according to the some states of custom data in Mapbox.
However, the custom data is the response from my Api server(NodeJs).

The flow is as like below;

When the scene starts, I send the ids of buildings(Gameobject names in Unity scene) as request parameter to the api server. The server sends the data of the buildings to Unity. So, I display the colors of the buildings according to this data in scene.

But, the problem is how to know when the all buildings of the scene are loaded.

Once all buildings are loaded, I can get all names of the buildings.

I used OnUpdated event, but I can't get the names. enter image description here

blue pine
  • 472
  • 6
  • 17

1 Answers1

1

I had a similar issue trying to access the terrain elevation data on OnUpdated, but it seems that it is not necessarily available at the time when OnUpdated is dispatched. You would think that when OnUpdated is dispatched, all processes related to the map updating are done, but, apparently, that is not the case.

I solved it in somewhat hacky way by using the OnTileFinished event, which will be dispatched for each loaded tile whenever it is done with it's processing. At least it seems that I can rely on the terrain data (for the given tile) being loaded at that time, so I would guess that the building data (for the given tile) would also be loaded.

It would be nice with some built in event when all tiles are finished, but I haven't been able to find such an event. I initially assumed that the OnUpdated would be such an event - the name sort of suggests it - but it doesn't seem to be so. Maybe it is a bug in the MapBox code - I don't know.

Unfortunately, it seems a bit like MapBox has stopped developing and maintaining the Unity SDK, the latest commit is from February 2020, but maybe they will get back to it at some point.