Skip to content

Commit 7417d94

Browse files
committed
First Draft for this task
1 parent eca861d commit 7417d94

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ namespace Editor
6464

6565
public class ModelExporter : System.IDisposable
6666
{
67+
// To be replaced by checkbox in Fbx Export settings
68+
bool removeAnimationsFromSkinnedMeshRenderer = true;
69+
6770
const string Title =
6871
"exports static meshes with materials and textures";
6972

@@ -1787,26 +1790,29 @@ protected void ExportAnimationClip (AnimationClip uniAnimClip, GameObject uniRoo
17871790
continue;
17881791
}
17891792

1790-
int index = QuaternionCurve.GetQuaternionIndex (uniCurveBinding.propertyName);
1791-
if (index >= 0) {
1792-
/* Rotation property; save it to convert quaternion -> euler later. */
1793-
RotationCurve rotCurve = GetRotationCurve<QuaternionCurve>(uniGO, uniAnimClip.frameRate, ref rotations);
1794-
rotCurve.SetCurve (index, uniAnimCurve);
1795-
continue;
1796-
}
1793+
// Do not create the curves if the component is a SkinnedMeshRenderer and if the option in FBX Export settings is toggled on.
1794+
if (!removeAnimationsFromSkinnedMeshRenderer || (removeAnimationsFromSkinnedMeshRenderer && uniGO.GetComponent<SkinnedMeshRenderer>() == null && uniGO.GetComponentInChildren<SkinnedMeshRenderer>() == null)) {
1795+
int index = QuaternionCurve.GetQuaternionIndex (uniCurveBinding.propertyName);
1796+
if (index >= 0) {
1797+
/* Rotation property; save it to convert quaternion -> euler later. */
1798+
RotationCurve rotCurve = GetRotationCurve<QuaternionCurve>(uniGO, uniAnimClip.frameRate, ref rotations);
1799+
rotCurve.SetCurve (index, uniAnimCurve);
1800+
continue;
1801+
}
17971802

1798-
index = EulerCurve.GetEulerIndex (uniCurveBinding.propertyName);
1799-
if (index >= 0) {
1800-
RotationCurve rotCurve = GetRotationCurve<EulerCurve> (uniGO, uniAnimClip.frameRate, ref rotations);
1801-
rotCurve.SetCurve (index, uniAnimCurve);
1802-
continue;
1803-
}
1803+
index = EulerCurve.GetEulerIndex (uniCurveBinding.propertyName);
1804+
if (index >= 0) {
1805+
RotationCurve rotCurve = GetRotationCurve<EulerCurve> (uniGO, uniAnimClip.frameRate, ref rotations);
1806+
rotCurve.SetCurve (index, uniAnimCurve);
1807+
continue;
1808+
}
18041809

1805-
/* simple property (e.g. intensity), export right away */
1806-
ExportAnimationCurve (uniGO, uniAnimCurve, uniAnimClip.frameRate,
1807-
uniCurveBinding.propertyName,
1808-
fbxScene,
1809-
fbxAnimLayer);
1810+
/* simple property (e.g. intensity), export right away */
1811+
ExportAnimationCurve (uniGO, uniAnimCurve, uniAnimClip.frameRate,
1812+
uniCurveBinding.propertyName,
1813+
fbxScene,
1814+
fbxAnimLayer);
1815+
}
18101816
}
18111817

18121818
/* now export all the quaternion curves */
@@ -2512,7 +2518,6 @@ protected Dictionary<GameObject, AnimationOnlyExportData> GetAnimationExportData
25122518
/// </summary>
25132519
protected bool ExportComponents(FbxScene fbxScene)
25142520
{
2515-
bool removeAnimationsFromSkinnedMeshRenderer = true;
25162521
var animationNodes = new HashSet<GameObject> ();
25172522

25182523
int numObjectsExported = 0;
@@ -2548,8 +2553,6 @@ protected bool ExportComponents(FbxScene fbxScene)
25482553
ExportLight (unityGo, fbxScene, fbxNode);
25492554
}
25502555

2551-
bool hasSkinned = unityGo.GetComponent<SkinnedMeshRenderer>() != null;
2552-
Debug.Log(unityGo.name + " hasSkinned " + hasSkinned.ToString());
25532556
// check if this object contains animation, keep track of it
25542557
// if it does
25552558
if (GameObjectHasAnimation (unityGo)) {

0 commit comments

Comments
 (0)