@@ -1899,6 +1899,8 @@ protected int ExportTransformHierarchy(
1899
1899
/// </summary>
1900
1900
protected bool ExportComponents ( FbxScene fbxScene )
1901
1901
{
1902
+ var animationNodes = new HashSet < GameObject > ( ) ;
1903
+
1902
1904
int numObjectsExported = 0 ;
1903
1905
int objectCount = MapUnityObjectToFbxNode . Count ;
1904
1906
foreach ( KeyValuePair < GameObject , FbxNode > entry in MapUnityObjectToFbxNode ) {
@@ -1932,13 +1934,35 @@ protected bool ExportComponents(FbxScene fbxScene)
1932
1934
ExportLight ( unityGo , fbxScene , fbxNode ) ;
1933
1935
}
1934
1936
1935
- // now (try) export animation
1936
- ExportAnimation ( unityGo , fbxScene ) ;
1937
+ // check if this object contains animation, keep track of it
1938
+ // if it does
1939
+ if ( GameObjectHasAnimation ( unityGo ) ) {
1940
+ animationNodes . Add ( unityGo ) ;
1941
+ }
1942
+ }
1937
1943
1944
+ // export all GameObjects that have animation
1945
+ if ( animationNodes . Count > 0 ) {
1946
+ foreach ( var go in animationNodes ) {
1947
+ ExportAnimation ( go , fbxScene ) ;
1948
+ }
1938
1949
}
1950
+
1939
1951
return true ;
1940
1952
}
1941
1953
1954
+ /// <summary>
1955
+ /// Checks if the GameObject has animation.
1956
+ /// </summary>
1957
+ /// <returns><c>true</c>, if object has animation, <c>false</c> otherwise.</returns>
1958
+ /// <param name="go">Go.</param>
1959
+ protected bool GameObjectHasAnimation ( GameObject go ) {
1960
+ return go != null &&
1961
+ go . GetComponent < Animator > ( ) ||
1962
+ go . GetComponent < Animation > ( ) ||
1963
+ go . GetComponent < UnityEngine . Playables . PlayableDirector > ( ) ;
1964
+ }
1965
+
1942
1966
/// <summary>
1943
1967
/// A count of how many GameObjects we are exporting, to have a rough
1944
1968
/// idea of how long creating the scene will take.
0 commit comments