I have a potential “fix” or workaround in UStaticMesh* UnFbx::FFbxImporter::ImportStaticMeshAsSingle()
I’ve changed the following:
int32 NumMaterials = FMath::Min(SortedMaterials.Num(),MaxMaterialIndex+1);
for (int32 MaterialIndex = 0; MaterialIndex < NumMaterials; ++MaterialIndex)
{
FMeshSectionInfo Info = StaticMesh->SectionInfoMap.Get(LODIndex, MaterialIndex);
int32 Index = StaticMesh->Materials.Find( SortedMaterials[MaterialIndex] );
if( Index == INDEX_NONE )
{
Index = StaticMesh->Materials.Num();
StaticMesh->Materials.Add(SortedMaterials[MaterialIndex]);
}
Info.MaterialIndex = Index;
StaticMesh->SectionInfoMap.Set(LODIndex, MaterialIndex, Info);
}
To be this:
int32 NumMaterials = FMath::Min(SortedMaterials.Num(),MaxMaterialIndex+1);
for (int32 MaterialIndex = 0; MaterialIndex < NumMaterials; ++MaterialIndex)
{
FMeshSectionInfo Info = StaticMesh->SectionInfoMap.Get(LODIndex, MaterialIndex);
int32 Index = StaticMesh->Materials.Find( SortedMaterials[MaterialIndex] );
if( Index == INDEX_NONE )
{
Index = StaticMesh->Materials.Num();
StaticMesh->Materials.Add(SortedMaterials[MaterialIndex]);
}
else
{
StaticMesh->Materials.Add( SortedMaterials[ Index ] );
Index = MaterialIndex;
}
Info.MaterialIndex = Index;
StaticMesh->SectionInfoMap.Set(LODIndex, MaterialIndex, Info);
}
I have a theory that this problem exists for any FBX that has multiple meshes that you are combining and you are NOT importing materials.