Skip to content

Commit 47d0050

Browse files
authored
Merge pull request #320 from Unity-Technologies/UNI-39449-timeline-clip-export-filename-select
UNI-39449 allow filename selection when exporting timeline clip
2 parents 21e7287 + 9c92be0 commit 47d0050

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2950,19 +2950,6 @@ private void ReplaceFile ()
29502950
[MenuItem(TimelineClipMenuItemName, false, 31)]
29512951
static void OnClipContextClick(MenuCommand command)
29522952
{
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-
29662953
var selectedObjects = Selection.objects;
29672954
foreach (var obj in selectedObjects)
29682955
{
@@ -2975,10 +2962,15 @@ static void OnClipContextClick(MenuCommand command)
29752962

29762963
GameObject animationTrackGObject = UnityEditor.Timeline.TimelineEditor.playableDirector.GetGenericBinding (editorClipAnimationTrack) as GameObject;
29772964

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

29812972
ExportObjects (filePath, myArray, AnimationExportType.timelineAnimationClip);
2973+
return;
29822974
}
29832975
}
29842976
}
@@ -3561,7 +3553,7 @@ public void Dispose ()
35613553
private string m_tempFilePath { get; set; }
35623554
private string m_lastFilePath { get; set; }
35633555

3564-
const string Extension = "fbx";
3556+
const string kFBXFileExtension = "fbx";
35653557

35663558
public enum AnimationExportType{
35673559
timelineAnimationClip,
@@ -3571,32 +3563,37 @@ public enum AnimationExportType{
35713563
}
35723564

35733565

3574-
private static string MakeFileName (string basename = "test", string extension = "fbx")
3566+
private static string MakeFileName (string basename = "test", string extension = kFBXFileExtension)
35753567
{
35763568
return basename + "." + extension;
35773569
}
35783570

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+
35793582
private static void OnExport (AnimationExportType exportType = AnimationExportType.all)
35803583
{
35813584

35823585
// 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-
35873586
GameObject [] selectedGOs = Selection.GetFiltered<GameObject> (SelectionMode.TopLevel);
35883587
string filename = null;
35893588
if (selectedGOs.Length == 1) {
3590-
filename = ConvertToValidFilename (selectedGOs [0].name + ".fbx");
3589+
filename = ConvertToValidFilename (selectedGOs [0].name + "." + kFBXFileExtension);
35913590
} else {
35923591
filename = string.IsNullOrEmpty (LastFilePath)
3593-
? MakeFileName (basename: FileBaseName, extension: Extension)
3592+
? MakeFileName (basename: FileBaseName, extension: kFBXFileExtension)
35943593
: System.IO.Path.GetFileName (LastFilePath);
35953594
}
35963595

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

36013598
if (string.IsNullOrEmpty (filePath)) {
36023599
return;

0 commit comments

Comments
 (0)