Getting access to generated Tiles GameObjects
Hello,
This is more a question than an issue I think, but I'm in a position where I'd like to gain access to each tiles gameobject after it's created.
I can see that the MapVizualiser keeps a dictionary of <UnwrappedTileId, UnityTile>, and I'm making a workaround right now with a method in MapVizualiser that returns a UnityTile from an UnwrappedTileId through a method in AbstractMap which I reference in my own sort of "MapController".
Is there a proper way through your interfaces to gain access to each GameObject when it's generated?
@Alexphauge Can you explain what you intend to do with the gameobjects? I ask because based on your requirements, you may be better off using a custom GameObjectModifiers or even a custom TerrainFactory.
What you are currently doing will work, but may be a bit messy. You could just fire an event from MapVisualizer each time a tile is generated.
We sort of have our own POI system, so we want to attach a script to each tile that keeps track of what's on top of it.
Currently, I solved my issue by having a method in MapVizualiser, and an even that tags along in AbstractMap on Tile_Loaded. - But I agree, it's messy. :)
I'll try and look into that custom Modifier/Factory to see if that might help clean up things.
As a sidenote, I noticed that I needed to have Android SDK 25 installed with the latest release from you. Had to upgrade to SDK 25, so the Android manifests would merge correctly.
It also gave me some problems with the Unity FacebookSDK with multiple versions of the same libraries, but it could be fixed by deleting Facebooks versions of the files. - Just posting it online if anyone else ends up having the same issue. :)
Had to delete these files: \FacebookSDK\Plugins\Android\libs\animated-vector-drawable-23.4.0.aar \FacebookSDK\Plugins\Android\libs\appcompat-v7-23.4.0.aar \FacebookSDK\Plugins\Android\libs\support-v4-23.4.0.aar \FacebookSDK\Plugins\Android\libs\support-vector-drawable-23.4.0.aar
But I guess I got an answer from your response, so I'll close this, feel free to write the above somewhere if anyone could use it. And thanks for the quick response and awesome Unity Integration 👍
I was way too quick and happy that I finally could build that I posted the above post... Now my app crashes instantly, and I'm betting it's because of the deleted libraries. - So nevermind that part, but still, thanks for the answer regarding my original question! :)
@Alexphauge Ooo, thanks for the heads up about android SDK conflicts!
Back to the original question, are you using a MeshFactory to generate buildings or anything? Are you tracking your own gameobjects that you place on top of the tiles? This sounds like an interesting use-case, and I'm just trying to plan the best notification system.
@zugaldia - wanted to get your thoughts on the android support library conflicts coming from other android plugins when used in the same project as the mapbox unity sdk. Is this something we can resolve by making a fat aar?
We're actually only using the terrain factory as we only need the map and the special style, we then have our own library with points of interest that we load in based on which tiles we have loaded. These points of interest are then just game objects of varying character that each tile itself "controls".
E.g. we make calls to our backend asking for certain POI around us in a 2km radius, after this we begin asking per tile we load in. Just in case people actually move that much while using our app.
I'm currently in a situation where I'm deleting random support libraries from either FacebookSDK or Mapbox trying to find the golden "match up". Also had to install specifically Android build tools for r25.2.5 because the newest apparently doesn't work with Unity. (Just another random note about this. :) )
And I'm still at a point where I can't build to Android without it crashing on startup because of the facebook SDK missing libraries, or I can't even get it on Android if it's missing some of Mapbox libraries. It works perfectly on iPhone 5S as a 👍 , I think this is my first time it's this way around.
We now fixed it so that both Facebook and Mapbox works, and the builds are actually doing okay.
We're currently trying to see if our Unity Cloud builds will work with this as well.
Deletion of these files ensured that our build worked: Mapbox\Core\Plugins\Android... ...animated-vector-drawable-25.1.0.aar ...appcompat-v7-25.1.0.aar ...support-compat-25.1.0.aar ...support-core-ui-25.1.0.aar ...support-core-utils-25.1.0.aar ...support-media-compay-25.1.0.aar ...support-v4-25.1.0.aar ...support-vector-drawable-25.1.0.aar
We're on 1.0.0 of Mapbox and 7.9.0 of FacebookSDK.
Edit 11 minutes later: Cloud build worked out as well. :)
@zugaldia - wanted to get your thoughts on the android support library conflicts coming from other android plugins when used in the same project as the mapbox unity sdk. Is this something we can resolve by making a fat aar?
It wouldn't. All a fat aar does is bundle all the dependencies together, but the support libraries would still be there.
For more context, Android support libraries (maintained and supported by Google) are a very common dependency in Android projects, including ours. We currently use annotations and key classes to handle permissions and notifications from these libraries, and this is likely gonna be the case in future versions. Glad to see though that the build error was fixed!
@Alexphauge Seems like for your POI use-case, you could think about making a PoiFactory class. I bet you could adapt the interface to suit your needs.