MagicaVoxel and Unity work great together for making voxel style video games. In this tutorial, we will discuss how to export your voxel models from MagicaVoxel into Unity.

So you finally created your voxel model inside of MagicaVoxel and now you’re ready to load it into Unity so you can make your video game. Now you might be asking, how do I export from MagicaVoxel to Unity? The good news is that MagicaVoxel supports a wide variety of export options. Specifically it supports the .OBJ file type which is supported by the Unity Game Engine. We’ll be going through the steps to import your voxel models into your Unity project. First we will show you how to export your model out of MagicaVoxel.

Getting Started

Over the years MagicaVoxel has become a great choice for game developers because of its various export options. Pair it up with the Unity game engine and anyone can make their first video game. There are two main steps that we will go over to get your voxel models into Unity. First we will export the voxel model out of MagicaVoxel. Then we will import the voxel model into Unity. We will cover these steps in more detail in the next section.

This tutorial uses MagicaVoxel 0.99.6 or newer. If you need help installing MagicaVoxel, view our previous tutorial How to Install MagicaVoxel. There you can find a step by step tutorial on getting MagicaVoxel running on your computer.

This tutorial supports Unity 2020 or newer. If you need help installing Unity, view our quick tutorial How to Install Unity. There you can find a step by step tutorial on getting the Unity Game Engine running on your computer.

How to Export from MagicaVoxel

Now before we can export a voxel model out of MagicaVoxel and place it inside of Unity, we must first understand what types of files Unity supports. Unity supports a wide array of model types including .FBX, .DAE and .OBJ. Now MagicaVoxel doesn’t support the first two, however it does export quite nicely to .OBJ. So to start we will export the model and select the .OBJ file format.

To access the export options inside of of MagicaVoxel, begin by opening your current voxel model or a new voxel model. For this example we used the “castle” model that ships with MagicaVoxel. When opened look to the bottom right of the window where it says Export.

When you open MagicaVoxel for the first time, the window might be collapsed. To uncollapse it simply click on the word Export. When you open it, you should see a series of buttons with different abbreviations. These are the different export options supported by the MagicaVoxel editor.

These are the Export formats supported by MagicaVoxel:

  1. OBJ – Export a 3D mesh using the .obj file format
  2. PLY – Export a file using the PLY (Polygon File Format) format
  3. MC –  Export a file using the MC (Marching Cubes) format
  4. XRAW – Export a XRAW volume
  5. SLAB – Export a SLAB6 vox volume
  6. QB – Export a QB volume for use with Qubicle
  7. VOX – Export a MagicaVoxel VOX file
  8. ISO – Export a Isometric pixel sprite (.png)
  9. 2D – Export a 2D sprite (.png)

For this tutorial you will select the first option, OBJ. Before you hit that button I find it useful to first create a folder on your computer where you will save your exported model to. The reason is because MagicaVoxel will create 3 separate files that actually make up your model that you will import into Unity. These 3 files include your model (.obj), your material (.mat) and your texture (.png). By using a folder we can just drag the folder into Unity as opposed to importing 3 files individually. In the example below I created a folder called “My Voxel Model”. So after you create your folder click the OBJ button in the export window. A save dialogue will appear where you can enter the name of the model. For the name I just used “MyVoxelModel.obj”.

Import Your Voxel Art into Unity

Now that you have your exported model, you are ready to import your model into Unity. If you exported your model into a folder this will super easy. Simply drag your folder into your Unity project. Its important to note that you must drag it inside of the Assets folder if not you won’t be able to use it in your scene. In the image below we dragged our newly created model into the Assets folder.

And that’s it! You should now be able to use your voxel art model inside of your Unity project! Next we are going to show you how to drag it into your scene.

How to Load A Voxel Model into a Unity Scene

It’s actually very easy to import your model into a Unity scene. Simply click and drag the .OBJ file that was inside of the folder into your Unity Scene. This is the file with the cube icon next to it.

After you drag it in, you should see your voxel model that you created inside of MagicaVoxel. As you probably noticed, Unity automatically detected what material to apply to your model and also what texture to use because it was in the same folder with your model.

And there you have it! Now you know how to successfully import a voxel model into Unity from MagicaVoxel. If you have any question or comments please leave them below. Thanks for reading.