I do a lot of work with Procedural Generation, and it’s obviously incredibly useful to be able to save this data for later use. In this article, I introduce tools to easily export a mesh to OBJ or FBX.

Exporting a GameObject or Mesh to FBX

Unity has a lot of packages, and even more preview packages. One of these is the aptly named “FBX Exporter”, currently in version 3.2.1, which allows us to export our Meshes to the FBX format for later use in Unity or in a Computer Graphics software, such as Maya or 3ds Max.

To get it, open the package manager in Unity, check the “Show preview packages” option, and download FBX Exporter.

dropdown FBX exporter
Right-click the object in the hierarchy and select "Export to FBX..."

From the options popup, you can then select the Level of Detail of the mesh (LOD), the object pivot…

export options FBX exporter
Export Options

What’s truly nice about this package is that it is capable of exporting GameObjects: you’re actually exporting the whole hierarchy of the GameObject so children will be exported as well.

3d viewer windows exported mesh
Our Exported Mesh in the Windows 3D viewer

Overall, even if this package is marked as in Preview, it works appropriately and even handles exporting animations. This Package is very straightforward to use, but if needed the Unity Documentation offers more details about its usage.

Exporting a Mesh to OBJ

While I’m mostly concerned about storing my gameobjects as prefabs for later use in game, it is also possible to export ONLY the mesh, by exporting it to the OBJ format. This should make it easier to import your mesh in a 3D modelling software compared to FBX.

The code for the export logic, as well as a custom inspector, are available on the Unity3D Wiki.