We’re building core support for Mapbox in Unity, the game engine used in many games - including Pokémon GO. This allows developers to use Studio to design maps to match the feel of their game. The plugin is a drop-in replacement for Unity’s plugin example: replace the binary to render the map on the scene. All the code is open source on Github.

Getting started

Start with the Low-level Native Plugin Interface, a plugin interface that allows you to render to a texture created in C# and pass it over to native code.

The original example draws a plasma effect to a texture using the CPU, which we replaced by drawing a nifty map using the GPU. Before rendering the map with OpenGL, we bind a framebuffer object and attach the texture passed by Unity as GL_COLOR_ATTACHMENT0, meaning that the rendering result will show up on the texture.

That’s all there is to it. Dynamically render fresh maps of any place in the world at runtime. We only redraw to the texture when new tile data arrives or when we update map state like the style, center coordinate, zoom level, etc. A great consequence is that Mapbox GL Native is idle most of the time, not consuming precious resources.

Don’t forget to set MAPBOX_ACCESS_TOKEN to your token ;)

Now rendering a map