@@ -1912,6 +1912,8 @@ protected int ExportTransformHierarchy(
1912
1912
/// </summary>
1913
1913
protected bool ExportComponents ( FbxScene fbxScene )
1914
1914
{
1915
+ var animationNodes = new HashSet < GameObject > ( ) ;
1916
+
1915
1917
int numObjectsExported = 0 ;
1916
1918
int objectCount = MapUnityObjectToFbxNode . Count ;
1917
1919
foreach ( KeyValuePair < GameObject , FbxNode > entry in MapUnityObjectToFbxNode ) {
@@ -1945,13 +1947,35 @@ protected bool ExportComponents(FbxScene fbxScene)
1945
1947
ExportLight ( unityGo , fbxScene , fbxNode ) ;
1946
1948
}
1947
1949
1948
- // now (try) export animation
1949
- ExportAnimation ( unityGo , fbxScene ) ;
1950
+ // check if this object contains animation, keep track of it
1951
+ // if it does
1952
+ if ( GameObjectHasAnimation ( unityGo ) ) {
1953
+ animationNodes . Add ( unityGo ) ;
1954
+ }
1955
+ }
1950
1956
1957
+ // export all GameObjects that have animation
1958
+ if ( animationNodes . Count > 0 ) {
1959
+ foreach ( var go in animationNodes ) {
1960
+ ExportAnimation ( go , fbxScene ) ;
1961
+ }
1951
1962
}
1963
+
1952
1964
return true ;
1953
1965
}
1954
1966
1967
+ /// <summary>
1968
+ /// Checks if the GameObject has animation.
1969
+ /// </summary>
1970
+ /// <returns><c>true</c>, if object has animation, <c>false</c> otherwise.</returns>
1971
+ /// <param name="go">Go.</param>
1972
+ protected bool GameObjectHasAnimation ( GameObject go ) {
1973
+ return go != null &&
1974
+ go . GetComponent < Animator > ( ) ||
1975
+ go . GetComponent < Animation > ( ) ||
1976
+ go . GetComponent < UnityEngine . Playables . PlayableDirector > ( ) ;
1977
+ }
1978
+
1955
1979
/// <summary>
1956
1980
/// A count of how many GameObjects we are exporting, to have a rough
1957
1981
/// idea of how long creating the scene will take.
0 commit comments