Skip to content

Commit 287b3a0

Browse files
committed
add empty AnimationOnlyExportData constructor
+ check if exportData found no dependencies, and return null if it didn't
1 parent 6b3435c commit 287b3a0

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

Packages/com.unity.formats.fbx/Editor/Scripts/FbxExporter.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2943,14 +2943,15 @@ public static IExportData GetExportData(GameObject rootObject, AnimationClip ani
29432943
if (exportOptions==null)
29442944
exportOptions = DefaultOptions;
29452945
Debug.Assert(exportOptions!=null);
2946-
2947-
var goToExport = new HashSet<GameObject>();
2948-
var animationClips = new Dictionary<AnimationClip, GameObject>();
2949-
var exportComponent = new Dictionary<GameObject, System.Type>();
2950-
2951-
var exportData = new AnimationOnlyExportData(animationClips, goToExport, exportComponent);
2946+
2947+
var exportData = new AnimationOnlyExportData();
29522948
exportData.CollectDependencies(animationClip, rootObject, exportOptions);
2953-
2949+
2950+
// could not find any dependencies, return null
2951+
if(exportData.Objects.Count <= 0)
2952+
{
2953+
return null;
2954+
}
29542955
return exportData;
29552956
}
29562957

@@ -2964,11 +2965,7 @@ internal static IExportData GetExportData(GameObject go, IExportOptions exportOp
29642965
var legacyAnim = go.GetComponentsInChildren<Animation>();
29652966
var genericAnim = go.GetComponentsInChildren<Animator>();
29662967

2967-
var goToExport = new HashSet<GameObject>();
2968-
var animationClips = new Dictionary<AnimationClip, GameObject>();
2969-
var exportComponent = new Dictionary<GameObject, System.Type>();
2970-
2971-
var exportData = new AnimationOnlyExportData(animationClips, goToExport, exportComponent);
2968+
var exportData = new AnimationOnlyExportData();
29722969

29732970
int depthFromRootAnimation = int.MaxValue;
29742971
Animation rootAnimation = null;

Packages/com.unity.formats.fbx/Editor/Scripts/IExportData.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public interface IExportData
1818
/// Export data containing what to export when
1919
/// exporting animation only.
2020
/// </summary>
21-
internal struct AnimationOnlyExportData : IExportData
21+
internal class AnimationOnlyExportData : IExportData
2222
{
2323
// map from animation clip to GameObject that has Animation/Animator
2424
// component containing clip
@@ -46,6 +46,14 @@ public AnimationOnlyExportData(
4646
this.defaultClip = null;
4747
}
4848

49+
public AnimationOnlyExportData()
50+
{
51+
this.animationClips = new Dictionary<AnimationClip, GameObject>();
52+
this.goExportSet = new HashSet<GameObject>();
53+
this.exportComponent = new Dictionary<GameObject, System.Type>();
54+
this.defaultClip = null;
55+
}
56+
4957
/// <summary>
5058
/// collect all object dependencies for given animation clip
5159
/// </summary>

0 commit comments

Comments
 (0)