MapsSDK-Unity
MapsSDK-Unity copied to clipboard
Cross-Scene Cache
Hi,
I have an app that works with loading and replacing scenes during runtime. Only the main "Game" scene is using the Maps SDK, the others (e.g., Menu scenes) don't.
Once the game scene is loaded, the map object starts loading the tiles and geometry from the internet. There are multiple Map objects in the scene by the way. This takes considerable time on every scene load, so I'm looking for a way to decrease or eliminate this loading time. The location typically doesn't change often, in fact usually very rarely, like every 10-50 scene loads.
I thought that the Map Session component holds a global cache so I tried to keep it alive using DontDestroyOnLoad between scene loads but this didn't work out. I found that probably every MapRenderer holds its own cache, right?
So what is the solution to have persistent cache for all my Map objects through scene loads? One additional requirement: the Map objects should be "'sleeping" when they are not needed so that they would not consume performance in other scenes.
Regards, M.Mitty
For every map object its MapRenderer component needs to be active continuously to keep the cache between scene loads? Is this correct?
It seems to me that if I disable the gameobject or just the MapRenderer component, the cache gets cleared and every tile starts reloading when the object or component gets reactivated.
Isn't there an option somewhere to have an in-game permanent cache for all map objects until the game is restarted?
Marking the MapSession as DontDestroyOnLoad is a good approach apart from any data caching implications, as it will ensure the developer key session is maintained through scene loads.
As for whether there is a global cache that multiple MapRenderer's can rely on: no, there is not. Each MapRenderer has a separate cache of data. (The MapSession can be shared between multiple MapRenderers though).
As for whether or not disabling clears a MapRenderer's cache, I'll need to double check on that.