Join Adam Crespi for an in-depth discussion in this video Importing meshes, part of Unity 5: 3D Essential Training.
- Unity is part of a production pipeline for making a game. It's where we're going to actually assemble our game putting in the interactivity and game play and placing assets. Those assets will probably be made somewhere else maybe in a 3D program like Autodesk 3ds Max or Maya, possibly in a digital sculpting program like Autodesk Mudbox or PixoLogic ZBrush. We'll see textures come in from Adobe Photoshop and Illustrator, and maybe we'll see the Quixel Suite for added dirt and decay, for example. We might also see other data such as audio files from Pro Tools or Audition or something similar, and motion captured in a Vicon system for example, or MotionBuilder.
How we bring in our assets then is really important and the good thing is we have a lot of control over what we do. Right now what I've done is to open up the 02_01 project and I've double-clicked on the 02_01_start scene. Our Unity scenes are shown with a Unity logo here, and double-clicking opens. Now that I've got it open, we can see in here I've got a main camera, a directional light, and a first person controller. And in that first person we can see our green capsule, and that defines the player volume, the blue sphere that defines the audio of which we don't have much at the moment, and our camera.
And I'm ready to bring in some meshes here to start to build out my game for importing. We have a couple of different things we can do. We can right-click in the Assets section of the Project window and choose Import New Asset and bring in an asset. Alternately, we can copy things into the Assets folder in an Explorer and do a mass import. Unity will recognize any change in there and automatically import in things. I'll bring in a single asset of a mesh first and show what that looks like in a pipeline. I'll click Import New Asset.
I've browsed in the Import New Asset dialog into the Exercise Files for Chapter Two. In here I've got some different folders, the 02_01 Unity project, an 02_3ds Max project which is a standalone 3ds Max project structure, and Audio folder, and 02_Maya which is a working Maya project. In general practice, I like to keep things separate. I'll build my assets, for example, in 3ds Max in a Max project, and then when I'm ready export those out and import them into Unity. I'll browse into 3ds Max and in here go into Export.
In here we can see some different folders, Archways, Conveyors, Doors, and so forth, and each of these contains FBXs of objects we're going to bring in. Unity imports by FBX which means we bring in FBX files as transfers from our native Max or Maya scenes. We can actually bring a Max or Maya file, for example, here into Unity, but what it actually does is to open up Max or Maya behind the scenes and export out an FBX. So it's better to export out an FBX and get all the parameters right.
I'll go into S_Archways, and in here I've got some different things, Archway_01, 02, and 03 and ArchwayA. I'll bring in ArchwayA to start and click Import. When a mesh comes in, we can select it here in the assets and see what's going on with it, its properties here in the Inspector. I've got my ArchwayA selected and clicking on the right arrow here shows me the actual pieces. There's the actual mesh for the archway, and an archway avatar which we can use if we get into Mecanim if we need.
As this archway's not going to be animated, I'm going to roll it up and just select the base archway FBX. When we import a mesh then, we have a lot of choices over what to do. First off, how big is it? Unity's native units are in meters. So if we're working in Maya, for example, where the native units are centimeters, we need to make sure that this scale factor compensates. In this case, because I exported this out in meters we see our scale factor at the top under Meshes is one. We've also got options in here. We can bring in all kinds of different things with our meshes such as blend shapes.
So if you're doing facial animation or maybe destruction driven by blend shapes you can bring them in. We also have the option in here to Generate Colliders and Generate Lightmap UVs. I'm going to leave off Generate Colliders for the moment as I want to do some custom Colliders possibly for this arch. Colliders are actually what we interact with here in Unity. We can bump into things or, well, not go through the wall. I will check Generate Lightmap UVs, and what this is going to do is make a second set of UVs on the object automatically unwrapped for baking the lighting.
Lastly, I can decide how I'm going to bring in things like normals and tangents, and typically the default settings of importing the normals and calculating the tangents are workable. We have choices over how our materials come in and what they're named. We have the option in here to import materials or not, and also are we naming them specifically? What we see is that because I've got Import Materials checked, and the material naming is by base texture name, Unity has created a Materials folder and in here if we double-click applying that transformation, we can see in here a material called archwayCS and that's named for that archway's diffuse texture.
What I'll do is typically make my materials as I want in Unity and apply them to objects. And I can apply multiple materials to an object by polygon if those polygons are assigned in 3ds Max or Maya. So what I'm going to do it uncheck Import Materials and now it'll just use Unity's default diffuse material until I go and apply one in. And this will avoid some duplication in case I re-import that object. When you're all done importing and configuring, click Apply. Now this mesh is in, there's just a basic gray material on it and it's ready for Colliders and placing in the scene.
If we drag it in as a the test, either into the scene, or into the hierarchy, we can actually see that arch. I'll press F to frame in on it, hold Alt and the left mouse to tumble around, and we can see, well, a stone arch held up by engaged columns in the sunlight. We can see that the smoothing groups came across so we've got some good definition on the stone. The columns have good definition on the base and capitals and it's ready for a material. We can bring in our meshes en masse then, and that's the really neat part. I've opened up an Explorer and I've browsed into the S_Archways directory in that 3ds Max project.
I'll take these FBX files, 01, 02, and 03, for example, press Control-C to copy, and go paste them into the Unity Assets folder. Here in the Unity Assets folder in my 02_01 project I'll right-click and paste in those FBXs. When we go back into Unity, we can see that Unity has recognized automatically the new assets in the Assets folder and imported them in. And we can select each one of them if we need to configure things like Lightmap UVs, Colliders, and so forth.
For all of mine, I'm going to turn off Importing Materials and I will Generate Lightmap UVs. And then clicking on a new object forces me to Apply or Revert. Now that my objects are in, I'm ready to start getting materials on and bringing in textures and other assets to build my game.
- Setting up the project
- Creating a player controller
- Importing assets, including models, audio, and textures
- Generating colliders
- Creating prefabs
- Applying materials
- Creating animation
- Designing a basic game level
- Lighting the level
- Creating particle systems
- Adding audio
- Building the game for desktop or mobile deployment