@@ -2950,19 +2950,6 @@ private void ReplaceFile ()
2950
2950
[ MenuItem ( TimelineClipMenuItemName , false , 31 ) ]
2951
2951
static void OnClipContextClick ( MenuCommand command )
2952
2952
{
2953
- // Now that we know we have stuff to export, get the user-desired path.
2954
- string directory = string . IsNullOrEmpty ( LastFilePath )
2955
- ? Application . dataPath
2956
- : System . IO . Path . GetDirectoryName ( LastFilePath ) ;
2957
-
2958
- string title = "Select the folder in which the animation files from the timeline will be exported" ;
2959
- string folderPath = EditorUtility . SaveFolderPanel ( title , directory , "" ) ;
2960
-
2961
- if ( string . IsNullOrEmpty ( folderPath ) )
2962
- {
2963
- return ;
2964
- }
2965
-
2966
2953
var selectedObjects = Selection . objects ;
2967
2954
foreach ( var obj in selectedObjects )
2968
2955
{
@@ -2975,10 +2962,15 @@ static void OnClipContextClick(MenuCommand command)
2975
2962
2976
2963
GameObject animationTrackGObject = UnityEditor . Timeline . TimelineEditor . playableDirector . GetGenericBinding ( editorClipAnimationTrack ) as GameObject ;
2977
2964
2978
- string filePath = string . Format ( AnimFbxFileFormat , folderPath , animationTrackGObject . name , timeLineClip . displayName ) ;
2965
+ string filePath = GetExportFilePath ( animationTrackGObject . name + "@" + timeLineClip . animationClip . name ) ;
2966
+ if ( string . IsNullOrEmpty ( filePath ) ) {
2967
+ continue ;
2968
+ }
2969
+
2979
2970
UnityEngine . Object [ ] myArray = new UnityEngine . Object [ ] { animationTrackGObject , timeLineClip . animationClip } ;
2980
2971
2981
2972
ExportObjects ( filePath , myArray , AnimationExportType . timelineAnimationClip ) ;
2973
+ return ;
2982
2974
}
2983
2975
}
2984
2976
}
@@ -3561,7 +3553,7 @@ public void Dispose ()
3561
3553
private string m_tempFilePath { get ; set ; }
3562
3554
private string m_lastFilePath { get ; set ; }
3563
3555
3564
- const string Extension = "fbx" ;
3556
+ const string kFBXFileExtension = "fbx" ;
3565
3557
3566
3558
public enum AnimationExportType {
3567
3559
timelineAnimationClip ,
@@ -3571,32 +3563,37 @@ public enum AnimationExportType{
3571
3563
}
3572
3564
3573
3565
3574
- private static string MakeFileName ( string basename = "test" , string extension = "fbx" )
3566
+ private static string MakeFileName ( string basename = "test" , string extension = kFBXFileExtension )
3575
3567
{
3576
3568
return basename + "." + extension ;
3577
3569
}
3578
3570
3571
+
3572
+ private static string GetExportFilePath ( string filenameSuggestion = "" ) {
3573
+ var directory = string . IsNullOrEmpty ( LastFilePath )
3574
+ ? Application . dataPath
3575
+ : System . IO . Path . GetDirectoryName ( LastFilePath ) ;
3576
+
3577
+ var title = string . Format ( "Export To FBX ({0})" , FileBaseName ) ;
3578
+
3579
+ return EditorUtility . SaveFilePanel ( title , directory , filenameSuggestion , kFBXFileExtension ) ;
3580
+ }
3581
+
3579
3582
private static void OnExport ( AnimationExportType exportType = AnimationExportType . all )
3580
3583
{
3581
3584
3582
3585
// Now that we know we have stuff to export, get the user-desired path.
3583
- var directory = string . IsNullOrEmpty ( LastFilePath )
3584
- ? Application . dataPath
3585
- : System . IO . Path . GetDirectoryName ( LastFilePath ) ;
3586
-
3587
3586
GameObject [ ] selectedGOs = Selection . GetFiltered < GameObject > ( SelectionMode . TopLevel ) ;
3588
3587
string filename = null ;
3589
3588
if ( selectedGOs . Length == 1 ) {
3590
- filename = ConvertToValidFilename ( selectedGOs [ 0 ] . name + ".fbx" ) ;
3589
+ filename = ConvertToValidFilename ( selectedGOs [ 0 ] . name + "." + kFBXFileExtension ) ;
3591
3590
} else {
3592
3591
filename = string . IsNullOrEmpty ( LastFilePath )
3593
- ? MakeFileName ( basename : FileBaseName , extension : Extension )
3592
+ ? MakeFileName ( basename : FileBaseName , extension : kFBXFileExtension )
3594
3593
: System . IO . Path . GetFileName ( LastFilePath ) ;
3595
3594
}
3596
3595
3597
- var title = string . Format ( "Export Model FBX ({0})" , FileBaseName ) ;
3598
-
3599
- var filePath = EditorUtility . SaveFilePanel ( title , directory , filename , "fbx" ) ;
3596
+ var filePath = GetExportFilePath ( filename ) ;
3600
3597
3601
3598
if ( string . IsNullOrEmpty ( filePath ) ) {
3602
3599
return ;
0 commit comments