I have yet to have any real problems with the Unity asset importing features, but the reason I wanted to write this article was to explain some of the quirks that might make things easier for new Unity developers. In this article, the two major things I want to cover are:
Importing textured 3d models into your game
Importing sound files and using them correctly
To begin, we’re going to start with 3d models. Personally, I’ve been using Cheetah3d which is a very inexpensive and basic modeling program. You can also use Blender as a no-cost alternative, and you really shouldn’t have major issues regardless of the file type you prefer. While Cheetah3d defaults to a .jas type of file, I have now taken to saving as .fbx because it seems to be more common and universal for other modeling programs. However, it’s important to note that Unity itself has no issue reading or importing any of the file types I’ve come across.
Obviously, the first thing we want to do here is design and texture a 3d model. For this article, I chose to use a terra-cotta pouring vase, seen below within Cheetah3d.
When rendered within the 3d modeling program, we get something like this:
To understand the path ahead, what we want to end up with here are basically 2 files – the object itself which is a series of polygons, and the texture that wraps around those polygons. If we were just to save it and import it now, we would end up with just a shape without any texture. To get the textures into a usable file, we simply bake them into a .png picture file.
We don’t need to know how everything works exactly except that our program has a UV editor and an option to bake the texture for us. I select the object, select “bake texture” from the menu, and open the UV editor to see this:
On the left, you can see the flat mapping of every polygon that can be affected by applied textures. You’ll notice that on the right, I’ve chosen UV1 and set a decent texture resolution of 1024×1024. When this picture is rendered, we get a result that looks like this:
Save your main file wherever you like, and be sure to save this image file along with it. Within Unity, we can right-click on our project window to get the option to “Import new Asset” or “Open in Explorer (or Finder)”. Whichever you choose, add your files into your game assets and you’ll see Unity work for a moment to calculate everything it needs.
Once it’s within your project window, you can manipulate settings on the prefab that Unity creates. Before anything else, be sure to drop your texture image file onto the little window within the material object. With this file added, you can see in the preview window of the 3d model prefab exactly how everything is rendered.
In some cases, the object may look a bit funky at this point. This is something that was slightly frustrating to me early on, but I found that Unity compensates through the inspector window and can correct the display. Take a look at the pictures below and you’ll see the rendering difference when “Normals” are imported versus calculated for this model:
Once you have your object set up correctly, drag it from your project window into the scene and take a look – hopefully everything looks as you expect. There are many more advanced ways to work with materials and texturizing, so if things are not exact, you can change your resolution or settings within your modeling program to your liking.
Another important thing to note is that if you work with the saved model file directly from your assets folder, you can change your model on the fly. Simply edit and save to instantly update everything within unity. (keep in mind you may need to bake your texture again if you make big changes).
While I’ve yet to work with the major professional modeling applications such as Maya or 3d Studio Max, I can’t imagine they would be much tougher than what we’ve done here with Cheetah. I look forward to working with those programs when I have the chance and perhaps writing a more specific tutorial if the process is different.
On the next page, we’ll work with importing and utilizing sound files within our project.