Skip to content

Commit aca9450

Browse files
committed
Merge branch 'master' into UNI-35294-export-legacy-skinned-mesh-anim
2 parents 1abbe9a + 52a5771 commit aca9450

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,6 +1912,8 @@ protected int ExportTransformHierarchy(
19121912
/// </summary>
19131913
protected bool ExportComponents(FbxScene fbxScene)
19141914
{
1915+
var animationNodes = new HashSet<GameObject> ();
1916+
19151917
int numObjectsExported = 0;
19161918
int objectCount = MapUnityObjectToFbxNode.Count;
19171919
foreach (KeyValuePair<GameObject, FbxNode> entry in MapUnityObjectToFbxNode) {
@@ -1945,13 +1947,35 @@ protected bool ExportComponents(FbxScene fbxScene)
19451947
ExportLight (unityGo, fbxScene, fbxNode);
19461948
}
19471949

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+
}
19501956

1957+
// export all GameObjects that have animation
1958+
if (animationNodes.Count > 0) {
1959+
foreach (var go in animationNodes) {
1960+
ExportAnimation (go, fbxScene);
1961+
}
19511962
}
1963+
19521964
return true;
19531965
}
19541966

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+
19551979
/// <summary>
19561980
/// A count of how many GameObjects we are exporting, to have a rough
19571981
/// idea of how long creating the scene will take.

0 commit comments

Comments
 (0)