Material Indices from Blender are different in Unity

I am making a collection of modular road pieces. The models are correctly importing, and look good. so, the materials aren’t wrong - only their ‘order’.
The models all have the same 7 materials used in them, and I set them up deliberately in this order: (mat 1 is there, but occluded)

When I import the model into unity, the materials array has them in a different order. Furthermore, that order is different for every different road piece, even though that isn’t the case in blender. This is really bad for me, as there could be hundreds of different ones, and I want to be able to select all of them and change, say, element #2, confident in the knowledge that element #2 always refers to the road surface mat.

Basically, I want to know

  • how unity orders the materials of incoming models
  • how I can change that order and force it to be consistent across all meshes

Thanks for your time!

Here is a workaround: Unity orders the mats by the order it encounters them per vertex. In blender 2.7 and up (and possibly others that I haven’t tested) the option ‘specials (w) > sort elements > material’ will sort the vertices to be in order of their material indices. This will solve the issue.

Take a look at this