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