Skip to content

Commit f594421

Browse files
committed
only export camera if mesh hasn't been exported
1 parent 2f2c4b1 commit f594421

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ protected bool ExportInstance (GameObject unityGo, FbxNode fbxNode, FbxScene fbx
766766
/// <summary>
767767
/// Exports camera component
768768
/// </summary>
769-
protected bool ExportCamera (GameObject unityGO, FbxScene fbxScene, FbxNode fbxNode, bool addAsChildNode=false)
769+
protected bool ExportCamera (GameObject unityGO, FbxScene fbxScene, FbxNode fbxNode)
770770
{
771771
Camera unityCamera = unityGO.GetComponent<Camera> ();
772772
if (unityCamera == null) {
@@ -806,29 +806,22 @@ protected bool ExportCamera (GameObject unityGO, FbxScene fbxScene, FbxNode fbxN
806806
// FarPlane
807807
fbxCamera.SetFarPlane (unityCamera.farClipPlane*100);
808808

809-
FbxNode cameraNode = fbxNode;
810-
// fbxNode already has a node attribute, so add the camera as a child of fbxNode
811-
if (addAsChildNode) {
812-
cameraNode = FbxNode.Create (fbxScene, GetUniqueName (unityGO.name + "_Camera"));
813-
fbxNode.AddChild (cameraNode);
814-
}
815-
816809
// Export backgroundColor as a custom property
817810
// NOTE: export on fbxNode so that it will show up in Maya
818-
ExportColorProperty (cameraNode, unityCamera.backgroundColor,
811+
ExportColorProperty (fbxNode, unityCamera.backgroundColor,
819812
MakeName("backgroundColor"),
820813
"The color with which the screen will be cleared.");
821814

822815
// Export clearFlags as a custom property
823816
// NOTE: export on fbxNode so that it will show up in Maya
824-
ExportIntProperty (cameraNode, (int)unityCamera.clearFlags,
817+
ExportIntProperty (fbxNode, (int)unityCamera.clearFlags,
825818
MakeName("clearFlags"),
826819
"How the camera clears the background.");
827820

828-
cameraNode.SetNodeAttribute (fbxCamera);
821+
fbxNode.SetNodeAttribute (fbxCamera);
829822

830823
// make the last camera exported the default camera
831-
DefaultCamera = cameraNode.GetName ();
824+
DefaultCamera = fbxNode.GetName ();
832825

833826
return true;
834827
}
@@ -939,10 +932,10 @@ protected int ExportComponents (
939932
exportedMesh = ExportMesh (unityGo, fbxNode);
940933
}
941934

942-
// try export camera
943-
// if a mesh has already been added to fbxNode, add camera as child node of fbxNode
944-
bool addAsChildNode = exportedMesh? true : false; // adding this extra step so it's clearer what we are passing
945-
ExportCamera(unityGo, fbxScene, fbxNode, addAsChildNode);
935+
// export camera, but only if no mesh was exported
936+
if (!exportedMesh) {
937+
ExportCamera (unityGo, fbxScene, fbxNode);
938+
}
946939

947940
if (Verbose)
948941
Debug.Log (string.Format ("exporting {0}", fbxNode.GetName ()));

0 commit comments

Comments
 (0)