@@ -82,8 +82,8 @@ 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..." ;
86
- const string TimelineClipMenuItemName = "GameObject/Export Selected Timeline Clip..." ;
85
+ const string ClipMenuItemName = "GameObject/FBX Exporter/ Export All Recorded Animation Clips..." ;
86
+ const string TimelineClipMenuItemName = "GameObject/FBX Exporter/ Export Selected Timeline Clip..." ;
87
87
88
88
89
89
const string AnimOnlyMenuItemName = "GameObject/Export Animation Only" ;
@@ -3081,35 +3081,36 @@ static void OnClipContextClick(MenuCommand command)
3081
3081
3082
3082
3083
3083
var selectedObjects = Selection . objects ;
3084
- foreach ( GameObject obj in selectedObjects )
3084
+ foreach ( GameObject editorClipSelected in selectedObjects )
3085
3085
{
3086
- ExportSingleTimelineClip ( obj , folderPath ) ;
3086
+ ExportSingleEditorClip ( editorClipSelected , folderPath ) ;
3087
3087
}
3088
3088
}
3089
3089
3090
- public static void ExportSingleTimelineClip ( GameObject obj , string folderPath )
3090
+ public static void ExportSingleEditorClip ( GameObject editorClipSelected , string folderPath )
3091
3091
{
3092
- if ( obj . GetType ( ) . Name . Contains ( "EditorClip" ) )
3092
+ if ( editorClipSelected . GetType ( ) . Name . Contains ( "EditorClip" ) )
3093
3093
{
3094
- var selClip = obj . GetType ( ) . GetProperty ( "clip" ) . GetValue ( obj , null ) ;
3094
+ var selClip = editorClipSelected . GetType ( ) . GetProperty ( "clip" ) . GetValue ( editorClipSelected , null ) ;
3095
3095
UnityEngine . Timeline . TimelineClip timeLineClip = selClip as UnityEngine . Timeline . TimelineClip ;
3096
3096
3097
- var selClipItem = obj . GetType ( ) . GetProperty ( "item" ) . GetValue ( obj , null ) ;
3097
+ var selClipItem = editorClipSelected . GetType ( ) . GetProperty ( "item" ) . GetValue ( editorClipSelected , null ) ;
3098
3098
var selClipItemParentTrack = selClipItem . GetType ( ) . GetProperty ( "parentTrack" ) . GetValue ( selClipItem , null ) ;
3099
3099
AnimationTrack editorClipAnimationTrack = selClipItemParentTrack as AnimationTrack ;
3100
-
3101
3100
GameObject animationTrackGObject = UnityEditor . Timeline . TimelineEditor . playableDirector . GetGenericBinding ( editorClipAnimationTrack ) as GameObject ;
3102
3101
3103
- Debug . Log ( "obj name: " + obj . name + " /clip name: " + editorClipAnimationTrack . name + " /timelineAssetName: " + animationTrackGObject . name ) ;
3104
-
3105
- string filePath = folderPath + "/" + animationTrackGObject . name + "@" + timeLineClip . animationClip . name + ".fbx" ;
3106
- Debug . Log ( "filepath: " + filePath ) ;
3107
- UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { animationTrackGObject , timeLineClip . animationClip } ;
3108
-
3109
- ExportObjects ( filePath , myArray , ExportType . timelineAnimationClip ) ;
3102
+ ExportSingleTimelineClip ( timeLineClip , folderPath , animationTrackGObject ) ;
3110
3103
}
3111
3104
}
3112
3105
3106
+ public static void ExportSingleTimelineClip ( TimelineClip timelineClipSelected , string folderPath , GameObject animationTrackGObject )
3107
+ {
3108
+ string filePath = folderPath + "/" + animationTrackGObject . name + "@" + timelineClipSelected . animationClip . name + ".fbx" ;
3109
+ //Debug.Log("filepath: " + filePath);
3110
+ UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { animationTrackGObject , timelineClipSelected . animationClip } ;
3111
+ ExportObjects ( filePath , myArray , AnimationExportType . timelineAnimationClip ) ;
3112
+ }
3113
+
3113
3114
/// <summary>
3114
3115
/// GameObject/Export All Recorded Animation Clips...
3115
3116
/// </summary>
@@ -3147,31 +3148,31 @@ public static void OnPlayableDirectorGameObjectContextClick(MenuCommand command)
3147
3148
}
3148
3149
}
3149
3150
3150
- foreach ( GameObject obj in selection )
3151
+ foreach ( GameObject objectWithPlayableDirector in selection )
3151
3152
{
3152
- ExportAllTimelineClips ( obj , folderPath ) ;
3153
+ ExportAllTimelineClips ( objectWithPlayableDirector , folderPath ) ;
3153
3154
}
3154
3155
}
3155
3156
3156
-
3157
- public static void ExportAllTimelineClips ( GameObject obj , string folderPath )
3157
+ public static void ExportAllTimelineClips ( GameObject objectWithPlayableDirector , string folderPath )
3158
3158
{
3159
- Debug . Log ( obj . GetType ( ) . BaseType . ToString ( ) + ":" + obj . name ) ;
3159
+ Debug . Log ( objectWithPlayableDirector . GetType ( ) . BaseType . ToString ( ) + ":" + objectWithPlayableDirector . name ) ;
3160
3160
3161
- PlayableDirector pd = obj . GetComponent < PlayableDirector > ( ) ;
3161
+ PlayableDirector pd = objectWithPlayableDirector . GetComponent < PlayableDirector > ( ) ;
3162
3162
if ( pd != null )
3163
3163
{
3164
3164
foreach ( PlayableBinding output in pd . playableAsset . outputs )
3165
3165
{
3166
3166
AnimationTrack at = output . sourceObject as AnimationTrack ;
3167
3167
3168
3168
GameObject atObject = pd . GetGenericBinding ( output . sourceObject ) as GameObject ;
3169
-
3170
- string filePath = folderPath + "/" + atObject . name + "@" + at . name + ".fbx" ;
3171
- Debug . Log ( "filepath: " + filePath ) ;
3172
- UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { atObject , at } ;
3173
-
3174
- ExportObjects ( filePath , myArray , ExportType . timelineAnimationTrack ) ;
3169
+ // One file by animation clip
3170
+ foreach ( TimelineClip timeLineClip in at . GetClips ( ) )
3171
+ {
3172
+ string filePath = folderPath + "/" + atObject . name + "@" + timeLineClip . animationClip . name + ".fbx" ;
3173
+ UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { atObject , timeLineClip . animationClip } ;
3174
+ ExportObjects ( filePath , myArray , AnimationExportType . timelineAnimationClip ) ;
3175
+ }
3175
3176
}
3176
3177
}
3177
3178
}
@@ -3238,7 +3239,7 @@ static void OnAnimOnlyContextItem (MenuCommand command)
3238
3239
return ;
3239
3240
}
3240
3241
3241
- OnExport ( ExportType . componentAnimation ) ;
3242
+ OnExport ( AnimationExportType . componentAnimation ) ;
3242
3243
}
3243
3244
3244
3245
/// <summary>
@@ -3689,7 +3690,7 @@ public void Dispose ()
3689
3690
3690
3691
const string Extension = "fbx" ;
3691
3692
3692
- public enum ExportType {
3693
+ public enum AnimationExportType {
3693
3694
timelineAnimationClip ,
3694
3695
timelineAnimationTrack ,
3695
3696
componentAnimation ,
@@ -3702,7 +3703,7 @@ private static string MakeFileName (string basename = "test", string extension =
3702
3703
return basename + "." + extension ;
3703
3704
}
3704
3705
3705
- private static void OnExport ( ExportType exportType = ExportType . all )
3706
+ private static void OnExport ( AnimationExportType exportType = AnimationExportType . all )
3706
3707
{
3707
3708
3708
3709
// Now that we know we have stuff to export, get the user-desired path.
@@ -3739,7 +3740,7 @@ private static void OnExport (ExportType exportType = ExportType.all)
3739
3740
/// Export a list of (Game) objects to FBX file.
3740
3741
/// Use the SaveFile panel to allow user to enter a file name.
3741
3742
/// <summary>
3742
- public static string ExportObjects ( string filePath , UnityEngine . Object [ ] objects = null , ExportType exportType = ExportType . all /*, bool animOnly = false*/ )
3743
+ public static string ExportObjects ( string filePath , UnityEngine . Object [ ] objects = null , AnimationExportType exportType = AnimationExportType . all /*, bool animOnly = false*/ )
3743
3744
{
3744
3745
LastFilePath = filePath ;
3745
3746
@@ -3755,19 +3756,19 @@ public static string ExportObjects (string filePath, UnityEngine.Object[] object
3755
3756
Dictionary < GameObject , AnimationOnlyExportData > animationExportData = null ;
3756
3757
switch ( exportType )
3757
3758
{
3758
- case ExportType . timelineAnimationClip :
3759
+ case AnimationExportType . timelineAnimationClip :
3759
3760
GameObject rootObject = ModelExporter . GetGameObject ( objects [ 0 ] ) ;
3760
3761
AnimationClip timelineClip = objects [ 1 ] as AnimationClip ;
3761
3762
List < AnimationClip > clipList = new List < AnimationClip > ( ) ;
3762
3763
clipList . Add ( timelineClip ) ;
3763
3764
animationExportData = fbxExporter . GetTimelineAnimationExportData ( rootObject , clipList ) ;
3764
3765
break ;
3765
- case ExportType . timelineAnimationTrack :
3766
+ case AnimationExportType . timelineAnimationTrack :
3766
3767
GameObject rootObject2 = ModelExporter . GetGameObject ( objects [ 0 ] ) ;
3767
3768
AnimationTrack timelineTrack = objects [ 1 ] as AnimationTrack ;
3768
3769
animationExportData = fbxExporter . GetAnimationExportDataFromAnimationTrack ( rootObject2 , timelineTrack ) ;
3769
3770
break ;
3770
- case ExportType . componentAnimation :
3771
+ case AnimationExportType . componentAnimation :
3771
3772
HashSet < GameObject > gos = new HashSet < GameObject > ( ) ;
3772
3773
foreach ( var obj in objects )
3773
3774
{
@@ -3789,7 +3790,7 @@ public static string ExportObjects (string filePath, UnityEngine.Object[] object
3789
3790
return null ;
3790
3791
}
3791
3792
3792
- public static string ExportObject ( string filePath , UnityEngine . Object root , ExportType exportType = ExportType . all /*, bool animOnly = false*/ )
3793
+ public static string ExportObject ( string filePath , UnityEngine . Object root , AnimationExportType exportType = AnimationExportType . all /*, bool animOnly = false*/ )
3793
3794
{
3794
3795
return ExportObjects ( filePath , new Object [ ] { root } , exportType ) ;
3795
3796
}
0 commit comments