Skip to content

Commit 8aae076

Browse files
committed
Force export of FbxNodeAttribute for Light and Camera on export of animation so that Maya importer will point the animation the right way.
When animation importing into Maya only update animation don't add new nodes and don't import Cameras and Lights.
1 parent aaf1c75 commit 8aae076

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,10 +2325,6 @@ public struct AnimationOnlyExportData {
23252325
// first clip to export
23262326
public AnimationClip defaultClip;
23272327

2328-
// TODO: find a better way to keep track of which components + properties we support
2329-
private static List<string> cameraProps = new List<string>{"field of view"};
2330-
private static List<string> lightProps = new List<string>{"m_Intensity", "m_SpotAngle", "m_Color.r", "m_Color.g", "m_Color.b"};
2331-
23322328
public AnimationOnlyExportData(
23332329
Dictionary<AnimationClip, GameObject> animClips,
23342330
HashSet<GameObject> exportSet,
@@ -2345,6 +2341,13 @@ public void ComputeObjectsInAnimationClips(
23452341
GameObject animationRootObject,
23462342
bool exportSkinnedMeshAnim = true
23472343
){
2344+
// Force export of FbxNodeAttribute for camera and light with animation
2345+
// so that they point the right way when imported into Maya.
2346+
if (animationRootObject.GetComponent<Light>())
2347+
this.exportComponent[animationRootObject] = typeof(Light);
2348+
else if (animationRootObject.GetComponent<Camera>())
2349+
this.exportComponent[animationRootObject] = typeof(Camera);
2350+
23482351
foreach (var animClip in animClips) {
23492352
if (this.animationClips.ContainsKey(animClip)) {
23502353
// we have already exported gameobjects for this clip
@@ -2368,11 +2371,10 @@ public void ComputeObjectsInAnimationClips(
23682371
continue;
23692372
}
23702373

2371-
if (lightProps.Contains (uniCurveBinding.propertyName)) {
2372-
this.exportComponent.Add (unityGo, typeof(Light));
2373-
} else if (cameraProps.Contains (uniCurveBinding.propertyName)) {
2374-
this.exportComponent.Add (unityGo, typeof(Camera));
2375-
}
2374+
if (unityGo.GetComponent<Light>())
2375+
this.exportComponent[unityGo] = typeof(Light);
2376+
else if (unityGo.GetComponent<Camera>())
2377+
this.exportComponent[unityGo] = typeof(Camera);
23762378

23772379
this.goExportSet.Add (unityGo);
23782380
}

Assets/Integrations/Autodesk/maya/scripts/unityCommands.mel

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,16 @@ proc importFile(string $filePathStr){
234234
storeAttribute($unityExportSet, $UnityFbxFileNameAttr, "");
235235
storeAttribute($unityExportSet, $UnityFbxNamespaceAttr, "");
236236
}
237-
237+
else
238+
{
239+
// Update animation only
240+
FBXImportMode -v exmerge;
241+
242+
// Don’t change the static values on the cameras and lights
243+
FBXImportCameras -v false;
244+
FBXImportLights -v false;
245+
}
246+
238247
if(`namespaceInfo -cur -an` != $targetNamespace){
239248
namespace -set $targetNamespace;
240249
}

0 commit comments

Comments
 (0)