Skip to content

Commit 24521b9

Browse files
committed
only export one selected clip + allow changing filename on export
1 parent ab5c025 commit 24521b9

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,19 +2945,6 @@ private void ReplaceFile ()
29452945
[MenuItem(TimelineClipMenuItemName, false, 31)]
29462946
static void OnClipContextClick(MenuCommand command)
29472947
{
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-
29612948
var selectedObjects = Selection.objects;
29622949
foreach (var obj in selectedObjects)
29632950
{
@@ -2972,10 +2959,15 @@ static void OnClipContextClick(MenuCommand command)
29722959

29732960
GameObject animationTrackGObject = UnityEditor.Timeline.TimelineEditor.playableDirector.GetGenericBinding (editorClipAnimationTrack) as GameObject;
29742961

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+
29762967
UnityEngine.Object[] myArray = new UnityEngine.Object[] { animationTrackGObject, timeLineClip.animationClip };
29772968

29782969
ExportObjects (filePath, myArray, AnimationExportType.timelineAnimationClip);
2970+
return;
29792971
}
29802972
}
29812973
}
@@ -3562,14 +3554,23 @@ private static string MakeFileName (string basename = "test", string extension =
35623554
return basename + "." + extension;
35633555
}
35643556

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+
35653570
private static void OnExport (AnimationExportType exportType = AnimationExportType.all)
35663571
{
35673572

35683573
// 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-
35733574
GameObject [] selectedGOs = Selection.GetFiltered<GameObject> (SelectionMode.TopLevel);
35743575
string filename = null;
35753576
if (selectedGOs.Length == 1) {
@@ -3580,9 +3581,7 @@ private static void OnExport (AnimationExportType exportType = AnimationExportTy
35803581
: System.IO.Path.GetFileName (LastFilePath);
35813582
}
35823583

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);
35863585

35873586
if (string.IsNullOrEmpty (filePath)) {
35883587
return;

0 commit comments

Comments
 (0)