From ba7982f06910e1c79d36e081138d9be9e325ee07 Mon Sep 17 00:00:00 2001 From: vkovec Date: Wed, 22 Jan 2020 14:32:17 -0500 Subject: [PATCH] fix nullrefexception when exporting object(s) without anim --- com.unity.formats.fbx/Editor/FbxExporter.cs | 48 +++++++++++---------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/com.unity.formats.fbx/Editor/FbxExporter.cs b/com.unity.formats.fbx/Editor/FbxExporter.cs index 3c494570e..727f81fd2 100644 --- a/com.unity.formats.fbx/Editor/FbxExporter.cs +++ b/com.unity.formats.fbx/Editor/FbxExporter.cs @@ -3482,31 +3482,35 @@ internal int ExportAll ( } } - foreach (var unityGo in revisedExportSet) + // Export animation if any + if (exportData != null) { - IExportData iData; - if(!exportData.TryGetValue(unityGo, out iData)) + foreach (var unityGo in revisedExportSet) { - continue; - } - var data = iData as AnimationOnlyExportData; - if(data == null) - { - Debug.LogWarningFormat("FBX Exporter: no animation export data found for {0}", unityGo.name); - continue; - } - // export animation - // export default clip first - if (data.defaultClip != null) - { - var defaultClip = data.defaultClip; - ExportAnimationClip(defaultClip, data.animationClips[defaultClip], fbxScene); - data.animationClips.Remove(defaultClip); - } + IExportData iData; + if (!exportData.TryGetValue(unityGo, out iData)) + { + continue; + } + var data = iData as AnimationOnlyExportData; + if (data == null) + { + Debug.LogWarningFormat("FBX Exporter: no animation export data found for {0}", unityGo.name); + continue; + } + // export animation + // export default clip first + if (data.defaultClip != null) + { + var defaultClip = data.defaultClip; + ExportAnimationClip(defaultClip, data.animationClips[defaultClip], fbxScene); + data.animationClips.Remove(defaultClip); + } - foreach (var animClip in data.animationClips) - { - ExportAnimationClip(animClip.Key, animClip.Value, fbxScene); + foreach (var animClip in data.animationClips) + { + ExportAnimationClip(animClip.Key, animClip.Value, fbxScene); + } } } // Set the scene's default camera.