Skip to content

Commit df46dee

Browse files
authored
Merge pull request #329 from Unity-Technologies/Uni-40627-LinkedPrefabBreakClonedMaterials
Uni-40627-LinkedPrefabBreakClonedMaterials - Fixed bug
2 parents bb44de2 + 712cc60 commit df46dee

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1263,9 +1263,23 @@ protected bool ExportInstance (GameObject unityGo, FbxNode fbxNode, FbxScene fbx
12631263
SharedMeshes [unityPrefabParent.name] = fbxNode.GetMesh ();
12641264
return true;
12651265
}
1266+
return false;
12661267
}
1268+
1269+
// We don't export the mesh because we already have it from the parent, but we still need to assign the material
1270+
var renderer = unityGo.GetComponent<Renderer>();
1271+
var materials = renderer ? renderer.sharedMaterials : null;
12671272

1268-
if (fbxMesh == null) return false;
1273+
Unity.FbxSdk.FbxSurfaceMaterial newMaterial = null;
1274+
if (materials != null)
1275+
{
1276+
foreach (var mat in materials) {
1277+
if (MaterialMap.TryGetValue(mat.name, out newMaterial));
1278+
{
1279+
fbxNode.AddMaterial(newMaterial);
1280+
}
1281+
}
1282+
}
12691283

12701284
// set the fbxNode containing the mesh
12711285
fbxNode.SetNodeAttribute (fbxMesh);

0 commit comments

Comments
 (0)