5
5
using UnityEditor ;
6
6
using Unity . FbxSdk ;
7
7
using System . Linq ;
8
+ using UnityEngine . Playables ;
9
+ using UnityEngine . Timeline ;
8
10
9
11
namespace FbxExporters
10
12
{
@@ -57,9 +59,7 @@ public static void Dump (this AnimationCurve animCurve, string message, float[]
57
59
58
60
namespace Editor
59
61
{
60
- using CustomExtensions ;
61
- using UnityEngine . Playables ;
62
- using UnityEngine . Timeline ;
62
+ using CustomExtensions ;
63
63
64
64
public class ModelExporter : System . IDisposable
65
65
{
@@ -82,7 +82,7 @@ public class ModelExporter : System.IDisposable
82
82
// being called only once regardless of what is selected.
83
83
const string MenuItemName = "GameObject/Export Model..." ;
84
84
85
- const string ClipMenuItemName = "GameObject/Export All Recorded Animation Clips..." ;
85
+ const string ClipMenuItemName = "GameObject/Export All Timeline Clips..." ;
86
86
const string TimelineClipMenuItemName = "GameObject/Export Selected Timeline Clip..." ;
87
87
88
88
@@ -1337,9 +1337,7 @@ protected bool ExportLight (GameObject unityGo, FbxScene fbxScene, FbxNode fbxNo
1337
1337
if ( ! MapLightType . TryGetValue ( unityLight . type , out fbxLightType ) )
1338
1338
return false ;
1339
1339
1340
- FbxLight fbxLight = FbxLight . Create ( fbxScene . GetFbxManager ( ) , unityLight . name ) ;
1341
-
1342
-
1340
+ FbxLight fbxLight = FbxLight . Create ( fbxScene . GetFbxManager ( ) , unityLight . name ) ;
1343
1341
1344
1342
// Set the type of the light.
1345
1343
fbxLight . LightType . Set ( fbxLightType ) ;
@@ -2484,7 +2482,7 @@ private int GetObjectToRootDepth(Transform startObject, Transform root){
2484
2482
/// <returns>The animation only hierarchy count.</returns>
2485
2483
/// <param name="exportSet">GameObject hierarchies selected for export.</param>
2486
2484
/// <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 )
2488
2486
{
2489
2487
// including any parents of animated objects that are exported
2490
2488
var completeExpSet = new HashSet < GameObject > ( ) ;
@@ -2917,7 +2915,7 @@ public int ExportAll (IEnumerable<UnityEngine.Object> unityExportSet, Dictionary
2917
2915
2918
2916
int count = 0 ;
2919
2917
if ( animOnly ) {
2920
- count = GetAnimOnlyHierarchyCount ( revisedExportSet , animationExportData ) ;
2918
+ count = GetAnimOnlyHierarchyCount ( animationExportData ) ;
2921
2919
} else {
2922
2920
count = GetHierarchyCount ( revisedExportSet ) ;
2923
2921
@@ -3097,7 +3095,7 @@ static void OnClipContextClick(MenuCommand command)
3097
3095
Debug . Log ( "filepath: " + filePath ) ;
3098
3096
UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { animationTrackGObject , timeLineClip . animationClip } ;
3099
3097
3100
- ExportObjects ( filePath , myArray , ExportType . timelineAnimationClip ) ;
3098
+ ExportObjects ( filePath , myArray , AnimationExportType . timelineAnimationClip ) ;
3101
3099
}
3102
3100
}
3103
3101
}
@@ -3158,7 +3156,7 @@ static void OnGameObjectWithTimelineContextClick(MenuCommand command)
3158
3156
Debug . Log ( "filepath: " + filePath ) ;
3159
3157
UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { atObject , at } ;
3160
3158
3161
- ExportObjects ( filePath , myArray , ExportType . timelineAnimationTrack ) ;
3159
+ ExportObjects ( filePath , myArray , AnimationExportType . timelineAnimationTrack ) ;
3162
3160
}
3163
3161
}
3164
3162
}
@@ -3170,8 +3168,6 @@ static void OnGameObjectWithTimelineContextClick(MenuCommand command)
3170
3168
[ MenuItem ( ClipMenuItemName , true , 31 ) ]
3171
3169
public static bool ValidateClipContextClick ( )
3172
3170
{
3173
- //return true;
3174
-
3175
3171
Object [ ] selection = Selection . objects ;
3176
3172
3177
3173
if ( selection == null || selection . Length == 0 )
@@ -3226,7 +3222,7 @@ static void OnAnimOnlyContextItem (MenuCommand command)
3226
3222
return ;
3227
3223
}
3228
3224
3229
- OnExport ( ExportType . componentAnimation ) ;
3225
+ OnExport ( AnimationExportType . componentAnimation ) ;
3230
3226
}
3231
3227
3232
3228
/// <summary>
@@ -3677,7 +3673,7 @@ public void Dispose ()
3677
3673
3678
3674
const string Extension = "fbx" ;
3679
3675
3680
- public enum ExportType {
3676
+ public enum AnimationExportType {
3681
3677
timelineAnimationClip ,
3682
3678
timelineAnimationTrack ,
3683
3679
componentAnimation ,
@@ -3690,7 +3686,7 @@ private static string MakeFileName (string basename = "test", string extension =
3690
3686
return basename + "." + extension ;
3691
3687
}
3692
3688
3693
- private static void OnExport ( ExportType exportType = ExportType . all )
3689
+ private static void OnExport ( AnimationExportType exportType = AnimationExportType . all )
3694
3690
{
3695
3691
3696
3692
// 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)
3727
3723
/// Export a list of (Game) objects to FBX file.
3728
3724
/// Use the SaveFile panel to allow user to enter a file name.
3729
3725
/// <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 )
3731
3727
{
3732
3728
LastFilePath = filePath ;
3733
3729
@@ -3743,19 +3739,20 @@ public static string ExportObjects (string filePath, UnityEngine.Object[] object
3743
3739
Dictionary < GameObject , AnimationOnlyExportData > animationExportData = null ;
3744
3740
switch ( exportType )
3745
3741
{
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
3747
3744
GameObject rootObject = ModelExporter . GetGameObject ( objects [ 0 ] ) ;
3748
3745
AnimationClip timelineClip = objects [ 1 ] as AnimationClip ;
3749
3746
List < AnimationClip > clipList = new List < AnimationClip > ( ) ;
3750
3747
clipList . Add ( timelineClip ) ;
3751
3748
animationExportData = fbxExporter . GetTimelineAnimationExportData ( rootObject , clipList ) ;
3752
3749
break ;
3753
- case ExportType . timelineAnimationTrack :
3750
+ case AnimationExportType . timelineAnimationTrack :
3754
3751
GameObject rootObject2 = ModelExporter . GetGameObject ( objects [ 0 ] ) ;
3755
3752
AnimationTrack timelineTrack = objects [ 1 ] as AnimationTrack ;
3756
3753
animationExportData = fbxExporter . GetAnimationExportDataFromAnimationTrack ( rootObject2 , timelineTrack ) ;
3757
3754
break ;
3758
- case ExportType . componentAnimation :
3755
+ case AnimationExportType . componentAnimation :
3759
3756
HashSet < GameObject > gos = new HashSet < GameObject > ( ) ;
3760
3757
foreach ( var obj in objects )
3761
3758
{
@@ -3777,7 +3774,7 @@ public static string ExportObjects (string filePath, UnityEngine.Object[] object
3777
3774
return null ;
3778
3775
}
3779
3776
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*/ )
3781
3778
{
3782
3779
return ExportObjects ( filePath , new Object [ ] { root } , exportType ) ;
3783
3780
}
0 commit comments