Random UV set export order

We are using 3ds max files with multiple objects inside them, as in-game we will always treat them as a group, and it makes the art pipeline easier.

However it appears that the FBX exporter writes the UV sets in an arbitrary order (well after much experimentation, I can't work out what the logic is). This was tested with a manual ASCII export and sometimes UVChannel_1 is first, and sometimes UVChannel_2 is listed first.

Now in Unity the project tree-view allows me to select 'Swap UVs', by selecting the object from beneath the Max file. However when I flip this, then it flips for all the objects in the Max file, and therefore I'm unable to patch over the FBX exporter's ideosyncrasies and get my diffuse and light-map UVS correctly assigned in Unity.

I'd be fine with patching each asset in Unity, but am unable because of the way they both flip together. Is this something that can be corrected in C# script, or do I need a fix in the engine?

Alternatively can anyone actually force the order of UVs in an FBX export?

You can write an AssetPostProcessor, that flips the uv's after the fbx has been imported, but before Unity writes the imported results to disk.

You'd need to find out a way to programmatically determine if the uv's need to be flipped though, but that seems solvable with a bit of creativity.

MaxTip: Max decides what uv's to export based on which materials are used by the object, and which maps are used by the materials, and which channels are used by the maps. If something in that chain changes, that could influence how the max fbx exporters exports your mesh.