mapbox-unity-sdk
mapbox-unity-sdk copied to clipboard
SpawnOnMap - instantiating only what’s visible
Hello, I’m having difficulty with this and would appreciate help.
I have a text file that has thousands of real world coordinates. I modified the spawnonmap.cs script to read from this file and instantiate prefabs at these locations, however as you can imagine, all 1000+ are being instantiated at runtime, causing for a massive load time. I have a script that deactivates these prefabs until they are within the players view, and then reactivates them, but they’re all still being created at start time.
How do I modify the spawnonmap.cs to only instantiate them when the player is within the coordinates that they are to be spawned at? I read previous answers to similar questions but I’m afraid I did not understand the responses, such as the suggestions here https://github.com/mapbox/mapbox-unity-sdk/issues/1809
this is really a game breaking issue and I’d like to get it taken care of. Thank you and I appreciate the help!
Actually, I figured it out, using SpawnPrefabAtGeoLocation and modifying the [POIPlacementScriptExample.cs] script, for anyone else wanting to know how to do the same. The documentation isn’t clear.
happy to hear you found a solution @autoOptions , sorry about the unclear api&documentation.