Skip to content

Commit 70f956c

Browse files
committed
Fixes asked in pull request
1 parent bd6b1b4 commit 70f956c

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using UnityEditor;
66
using Unity.FbxSdk;
77
using System.Linq;
8+
using UnityEngine.Playables;
9+
using UnityEngine.Timeline;
810

911
namespace FbxExporters
1012
{
@@ -57,9 +59,7 @@ public static void Dump (this AnimationCurve animCurve, string message, float[]
5759

5860
namespace Editor
5961
{
60-
using CustomExtensions;
61-
using UnityEngine.Playables;
62-
using UnityEngine.Timeline;
62+
using CustomExtensions;
6363

6464
public class ModelExporter : System.IDisposable
6565
{
@@ -82,7 +82,7 @@ public class ModelExporter : System.IDisposable
8282
// being called only once regardless of what is selected.
8383
const string MenuItemName = "GameObject/Export Model...";
8484

85-
const string ClipMenuItemName = "GameObject/Export All Recorded Animation Clips...";
85+
const string ClipMenuItemName = "GameObject/Export All Timeline Clips...";
8686
const string TimelineClipMenuItemName = "GameObject/Export Selected Timeline Clip...";
8787

8888

@@ -1337,9 +1337,7 @@ protected bool ExportLight (GameObject unityGo, FbxScene fbxScene, FbxNode fbxNo
13371337
if (!MapLightType.TryGetValue (unityLight.type, out fbxLightType))
13381338
return false;
13391339

1340-
FbxLight fbxLight = FbxLight.Create (fbxScene.GetFbxManager (), unityLight.name);
1341-
1342-
1340+
FbxLight fbxLight = FbxLight.Create (fbxScene.GetFbxManager (), unityLight.name);
13431341

13441342
// Set the type of the light.
13451343
fbxLight.LightType.Set(fbxLightType);
@@ -2484,7 +2482,7 @@ private int GetObjectToRootDepth(Transform startObject, Transform root){
24842482
/// <returns>The animation only hierarchy count.</returns>
24852483
/// <param name="exportSet">GameObject hierarchies selected for export.</param>
24862484
/// <param name="hierarchyToExportData">Map from GameObject hierarchy to animation export data.</param>
2487-
protected int GetAnimOnlyHierarchyCount(HashSet<GameObject> exportSet, Dictionary<GameObject, AnimationOnlyExportData> hierarchyToExportData)
2485+
protected int GetAnimOnlyHierarchyCount(Dictionary<GameObject, AnimationOnlyExportData> hierarchyToExportData)
24882486
{
24892487
// including any parents of animated objects that are exported
24902488
var completeExpSet = new HashSet<GameObject>();
@@ -2917,7 +2915,7 @@ public int ExportAll (IEnumerable<UnityEngine.Object> unityExportSet, Dictionary
29172915

29182916
int count = 0;
29192917
if(animOnly){
2920-
count = GetAnimOnlyHierarchyCount(revisedExportSet, animationExportData);
2918+
count = GetAnimOnlyHierarchyCount(animationExportData);
29212919
} else {
29222920
count = GetHierarchyCount (revisedExportSet);
29232921

@@ -3097,7 +3095,7 @@ static void OnClipContextClick(MenuCommand command)
30973095
Debug.Log("filepath: " + filePath);
30983096
UnityEngine.Object[] myArray = new UnityEngine.Object[] { animationTrackGObject, timeLineClip.animationClip };
30993097

3100-
ExportObjects(filePath, myArray, ExportType.timelineAnimationClip);
3098+
ExportObjects(filePath, myArray, AnimationExportType.timelineAnimationClip);
31013099
}
31023100
}
31033101
}
@@ -3158,7 +3156,7 @@ static void OnGameObjectWithTimelineContextClick(MenuCommand command)
31583156
Debug.Log("filepath: " + filePath);
31593157
UnityEngine.Object[] myArray = new UnityEngine.Object[] { atObject, at};
31603158

3161-
ExportObjects(filePath, myArray, ExportType.timelineAnimationTrack);
3159+
ExportObjects(filePath, myArray, AnimationExportType.timelineAnimationTrack);
31623160
}
31633161
}
31643162
}
@@ -3170,8 +3168,6 @@ static void OnGameObjectWithTimelineContextClick(MenuCommand command)
31703168
[MenuItem(ClipMenuItemName, true, 31)]
31713169
public static bool ValidateClipContextClick()
31723170
{
3173-
//return true;
3174-
31753171
Object[] selection = Selection.objects;
31763172

31773173
if (selection == null || selection.Length == 0)
@@ -3226,7 +3222,7 @@ static void OnAnimOnlyContextItem (MenuCommand command)
32263222
return;
32273223
}
32283224

3229-
OnExport (ExportType.componentAnimation);
3225+
OnExport (AnimationExportType.componentAnimation);
32303226
}
32313227

32323228
/// <summary>
@@ -3677,7 +3673,7 @@ public void Dispose ()
36773673

36783674
const string Extension = "fbx";
36793675

3680-
public enum ExportType{
3676+
public enum AnimationExportType{
36813677
timelineAnimationClip,
36823678
timelineAnimationTrack,
36833679
componentAnimation,
@@ -3690,7 +3686,7 @@ private static string MakeFileName (string basename = "test", string extension =
36903686
return basename + "." + extension;
36913687
}
36923688

3693-
private static void OnExport (ExportType exportType = ExportType.all)
3689+
private static void OnExport (AnimationExportType exportType = AnimationExportType.all)
36943690
{
36953691

36963692
// Now that we know we have stuff to export, get the user-desired path.
@@ -3727,7 +3723,7 @@ private static void OnExport (ExportType exportType = ExportType.all)
37273723
/// Export a list of (Game) objects to FBX file.
37283724
/// Use the SaveFile panel to allow user to enter a file name.
37293725
/// <summary>
3730-
public static string ExportObjects (string filePath, UnityEngine.Object[] objects = null, ExportType exportType = ExportType.all /*, bool animOnly = false*/)
3726+
public static string ExportObjects (string filePath, UnityEngine.Object[] objects = null, AnimationExportType exportType = AnimationExportType.all)
37313727
{
37323728
LastFilePath = filePath;
37333729

@@ -3743,19 +3739,20 @@ public static string ExportObjects (string filePath, UnityEngine.Object[] object
37433739
Dictionary<GameObject, AnimationOnlyExportData> animationExportData = null;
37443740
switch (exportType)
37453741
{
3746-
case ExportType.timelineAnimationClip:
3742+
case AnimationExportType.timelineAnimationClip:
3743+
// We expect the first argument in the list to be the GameObject, the second one is the Animation Clip/Track we are exporting from the timeline
37473744
GameObject rootObject = ModelExporter.GetGameObject(objects[0]);
37483745
AnimationClip timelineClip = objects[1] as AnimationClip;
37493746
List<AnimationClip> clipList = new List<AnimationClip>();
37503747
clipList.Add(timelineClip);
37513748
animationExportData = fbxExporter.GetTimelineAnimationExportData(rootObject, clipList);
37523749
break;
3753-
case ExportType.timelineAnimationTrack:
3750+
case AnimationExportType.timelineAnimationTrack:
37543751
GameObject rootObject2 = ModelExporter.GetGameObject(objects[0]);
37553752
AnimationTrack timelineTrack = objects[1] as AnimationTrack;
37563753
animationExportData = fbxExporter.GetAnimationExportDataFromAnimationTrack(rootObject2, timelineTrack);
37573754
break;
3758-
case ExportType.componentAnimation:
3755+
case AnimationExportType.componentAnimation:
37593756
HashSet<GameObject> gos = new HashSet<GameObject>();
37603757
foreach(var obj in objects)
37613758
{
@@ -3777,7 +3774,7 @@ public static string ExportObjects (string filePath, UnityEngine.Object[] object
37773774
return null;
37783775
}
37793776

3780-
public static string ExportObject (string filePath, UnityEngine.Object root, ExportType exportType = ExportType.all /*, bool animOnly = false*/)
3777+
public static string ExportObject (string filePath, UnityEngine.Object root, AnimationExportType exportType = AnimationExportType.all /*, bool animOnly = false*/)
37813778
{
37823779
return ExportObjects(filePath, new Object[] { root }, exportType);
37833780
}

Assets/FbxExporters/Editor/UnitTests/FbxAnimationTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ public void AnimOnlyExportTest(string prefabPath)
828828
// export fbx
829829
// get GameObject
830830
string filename = GetRandomFbxFilePath ();
831-
var exportedFilePath = ModelExporter.ExportObject (filename, originalGO, ModelExporter.ExportType.componentAnimation);
831+
var exportedFilePath = ModelExporter.ExportObject (filename, originalGO, ModelExporter.AnimationExportType.componentAnimation);
832832
Assert.That (exportedFilePath, Is.EqualTo (filename));
833833

834834
GameObject fbxObj = AssetDatabase.LoadMainAssetAtPath (filename) as GameObject;

0 commit comments

Comments
 (0)