Importing 3D Models to Unity - eisclimber/ExPresS-XR GitHub Wiki
Models for Unity can be found in the asset store and in hundreds of places on the internet. These can usually be dragged and dropped into Unity and are already ready to use. If you are new or inexperienced this might be a valid option as 3D modelling even simple shapes can be really hard. If you decide to create your own models, like when Scanning Objects to use in 3D there are some things that need to be accounted for.
Unity uses the most common files, like .fbx, .3ds and .obj. It can import other files, like Blender files, but these will usually be converted internally to fbx. This is why it is recommended to convert the models directly to fbxusing a §D modeling application likeblender. The following examples refer to blenderbut work similarly in other applications. These applications support more file types and can convert them tofbx`, via "File > Export > FBX".
Here are some things you will need to consider before exporting:
- Do not scale the mesh or apply the transform in your modeling Software. Make sure the scale of the object is (1, 1, 1).
- Different axis names: Be aware that the axis in
blenderand Unity are named differently. I.e., the up-direction iszandyrespectively. The default forward direction in Blender is positivey. - Planes are one-sided: Planes and other faces are rendered from both sides in Blender. Unity only renders the face from one side (in the direction of its normal vector). To fix this, either flip the faces if possible or duplicate and the flip the face.
- Recalculate Outside Normals: The normals might face the wrong ways when creating models. This results in some faces not being rendered correctly, as they face the wrong way. To fix this, select the object, go to edit mode, select all edges and go to "Mesh > Normals > Recalculate Outside"
- Copy Texture-Materials: When using simple Textures as Material Input with
.fbxand.blend-Files, they will be missing in Unity. To circumvent this, in Blender, go toFile > External Data > Unpack All Into Filesand select the first option to create a folder along your.blend-File containing all the materials. Then chooseFile > External Data > Pack All Into .blendto add them into the.blend-File and Export the Model as.fbxas normal. If you are exporting an FBX-Model this should already do the trick. If you want more control or are using a.blend-File there are a few more steps to take. Also, sometimes the FBX-Import does not work, so you will also have to do the next steps. Drag the Model AND the folder containing the unpacked Textures into Unity. On the model, clickExtract Materialsto allow editing of the model's Materials. Assign the Textures to their respective slot in the Materials Inspector (e.g. BaseMap, Normals, ...). A full Video-Tutorial can be found here. - Convert Complex Shader-Materials: Materials in Blender are not fully compatible with those Unity. You have the option to recreate your Materials in Unity or bake the Blender Materials to Textures as described here and proceed like Copying Texture-Materials.
- One Mesh per Material: Be aware that you'll might need to split the mesh depending on the material. E.g. one mesh for a window's frame, one for the handle, and one for the glass.
- To assign materials to a model in Unity, it must be dragged into the Scene view. Then apply the materials per drag and drop. When all have been assigned, drag the prefab from the "Hierarchy"-tab back to the File System and create a "Prefab Variant"
- Here are some more tutorials that might come in handy when creating models for a room, as described in the Room Creation Tutorial: Create Windows, For Creating Window Handles, The Mirror Tool and General Export.