|Home||Log In||Contact||Keep Me Posted||Public Meshes||Source Code||Articles||API & Applications|
When you import an FBX file into Unity the materials have names in the FBX file. Unity will match materials by name against the imported file. If you have a material called "Brick Color" in Unity and the FBX file contains a material called "Brick Color", Unity will use the existing material, regardless of the color values in the FBX file. This can make it seem as if the import isn't working because the colors seem wrong.
The Meshola project uses the FBX format as the container file format for export meshes. The plan is to use other formats, include JSON or definitions in C#, but realistically there has to be a format that can be used directly with other programs, and the FBX format is well suited to it. I'm using the FBX SDK available from Autodesk, its free and well documented, although there is a learning curve.
Importing files into Unity via the FBX format is not perfectly smooth, and at least some of the problems are related to Materials and to Textures.
In an FBX file each polygon in a mesh can have its own material defined for it. Here is a routine I wrote that takes a color and generates a new material, each with a unique name. I used this routine to generate a set of materials, each with a different color, one for each polygon in a mesh.
Here is how it looks in Unity
So what happens if I change the colors to blue for all polygons? Here is how it looks in the FBX previewer
But when I import this into Unity it looks like this. The colors haven't changed from the previous import.
However, when I view the materials list I find that the materials are there. When I modified the FBX file I didn't rename the materials so Unity matched them with the ones it already had, which had a different color.
If I delete the materials from the Material Library and re-import, the colors are correct.