@@ -2951,29 +2951,18 @@ private void ReplaceFile ()
2951
2951
[ MenuItem ( TimelineClipMenuItemName , false , 31 ) ]
2952
2952
static void OnClipContextClick ( MenuCommand command )
2953
2953
{
2954
- // Now that we know we have stuff to export, get the user-desired path.
2955
- string directory = string . IsNullOrEmpty ( LastFilePath )
2956
- ? Application . dataPath
2957
- : System . IO . Path . GetDirectoryName ( LastFilePath ) ;
2958
-
2959
- string title = "Select the folder in which the animation files from the timeline will be exported" ;
2960
- string folderPath = EditorUtility . SaveFolderPanel ( title , directory , "" ) ;
2961
-
2962
- if ( string . IsNullOrEmpty ( folderPath ) )
2963
- {
2964
- return ;
2965
- }
2966
- Debug . Log ( folderPath ) ;
2967
-
2968
2954
Object [ ] selectedObjects = Selection . objects ;
2969
2955
2970
2956
foreach ( Object editorClipSelected in selectedObjects )
2971
2957
{
2972
- ExportSingleEditorClip ( editorClipSelected , folderPath ) ;
2958
+ // export first selected editor clip.
2959
+ if ( ExportSingleEditorClip ( editorClipSelected ) ) {
2960
+ return ;
2961
+ }
2973
2962
}
2974
2963
}
2975
2964
2976
- public static void ExportSingleEditorClip ( Object editorClipSelected , string folderPath )
2965
+ public static bool ExportSingleEditorClip ( Object editorClipSelected )
2977
2966
{
2978
2967
if ( editorClipSelected . GetType ( ) . Name . Contains ( "EditorClip" ) )
2979
2968
{
@@ -2985,15 +2974,25 @@ public static void ExportSingleEditorClip(Object editorClipSelected, string fold
2985
2974
AnimationTrack editorClipAnimationTrack = selClipItemParentTrack as AnimationTrack ;
2986
2975
GameObject animationTrackGObject = UnityEditor . Timeline . TimelineEditor . playableDirector . GetGenericBinding ( editorClipAnimationTrack ) as GameObject ;
2987
2976
2988
- ExportSingleTimelineClip ( timeLineClip , folderPath , animationTrackGObject ) ;
2977
+ ExportSingleTimelineClip ( timeLineClip , animationTrackGObject ) ;
2978
+ return true ;
2989
2979
}
2980
+ return false ;
2990
2981
}
2991
2982
2992
- public static void ExportSingleTimelineClip ( TimelineClip timelineClipSelected , string folderPath , GameObject animationTrackGObject )
2983
+ public static void ExportSingleTimelineClip ( TimelineClip timelineClipSelected , GameObject animationTrackGObject , string filePath = null )
2993
2984
{
2994
- string filePath = folderPath + "/" + animationTrackGObject . name + "@" + timelineClipSelected . animationClip . name + ".fbx" ;
2995
- UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { animationTrackGObject , timelineClipSelected . animationClip } ;
2996
- ExportObjects ( filePath , myArray , AnimationExportType . timelineAnimationClip ) ;
2985
+ if ( string . IsNullOrEmpty ( filePath ) ) {
2986
+ filePath = GetExportFilePath ( animationTrackGObject . name + "@" + timelineClipSelected . displayName ) ;
2987
+ }
2988
+ if ( string . IsNullOrEmpty ( filePath ) ) {
2989
+ return ;
2990
+ }
2991
+ UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] {
2992
+ animationTrackGObject ,
2993
+ timelineClipSelected . animationClip
2994
+ } ;
2995
+ ExportObjects ( filePath , myArray , AnimationExportType . timelineAnimationClip ) ;
2997
2996
}
2998
2997
2999
2998
/// <summary>
@@ -3040,8 +3039,6 @@ public static void OnPlayableDirectorGameObjectContextClick(MenuCommand command)
3040
3039
3041
3040
public static void ExportAllTimelineClips ( GameObject objectWithPlayableDirector , string folderPath )
3042
3041
{
3043
- Debug . Log ( objectWithPlayableDirector . GetType ( ) . BaseType . ToString ( ) + ":" + objectWithPlayableDirector . name ) ;
3044
-
3045
3042
PlayableDirector pd = objectWithPlayableDirector . GetComponent < PlayableDirector > ( ) ;
3046
3043
if ( pd != null )
3047
3044
{
@@ -3050,13 +3047,12 @@ public static void ExportAllTimelineClips(GameObject objectWithPlayableDirector,
3050
3047
AnimationTrack at = output . sourceObject as AnimationTrack ;
3051
3048
3052
3049
GameObject atObject = pd . GetGenericBinding ( output . sourceObject ) as GameObject ;
3053
- // One file by animation clip
3054
- foreach ( TimelineClip timeLineClip in at . GetClips ( ) )
3055
- {
3056
- string filePath = folderPath + "/" + atObject . name + "@" + timeLineClip . animationClip . name + ".fbx" ;
3057
- UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { atObject , timeLineClip . animationClip } ;
3058
- ExportObjects ( filePath , myArray , AnimationExportType . timelineAnimationClip ) ;
3059
- }
3050
+ // One file by animation clip
3051
+ foreach ( TimelineClip timeLineClip in at . GetClips ( ) ) {
3052
+ string filePath = string . Format ( AnimFbxFileFormat , folderPath , atObject . name , timeLineClip . displayName ) ;
3053
+ UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { atObject , timeLineClip . animationClip } ;
3054
+ ExportObjects ( filePath , myArray , AnimationExportType . timelineAnimationClip ) ;
3055
+ }
3060
3056
}
3061
3057
}
3062
3058
}
@@ -3633,7 +3629,6 @@ private static void OnExport (AnimationExportType exportType = AnimationExportTy
3633
3629
/// Export a list of (Game) objects to FBX file.
3634
3630
/// Use the SaveFile panel to allow user to enter a file name.
3635
3631
/// <summary>
3636
- //public static string ExportObjects (string filePath, UnityEngine.Object[] objects = null, AnimationExportType exportType = AnimationExportType.all /*, bool animOnly = false*/)
3637
3632
public static string ExportObjects (
3638
3633
string filePath ,
3639
3634
UnityEngine . Object [ ] objects = null ,
@@ -3690,7 +3685,6 @@ public static string ExportObjects (
3690
3685
return null ;
3691
3686
}
3692
3687
3693
- //public static string ExportObject (string filePath, UnityEngine.Object root, AnimationExportType exportType = AnimationExportType.all /*, bool animOnly = false*/)
3694
3688
public static string ExportObject (
3695
3689
string filePath , UnityEngine . Object root ,
3696
3690
AnimationExportType exportType = AnimationExportType . all ,
0 commit comments