Skip to content

Commit b4f61bf

Browse files
committed
give error if user tries to export without filename
- also only close export options window if export succeeds
1 parent 497b9e3 commit b4f61bf

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

Assets/FbxExporters/Editor/ConvertToPrefabEditorWindow.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,18 @@ protected override void OnEnable ()
5050
m_prefabExtLabelWidth = m_fbxExtLabelStyle.CalcSize (new GUIContent (".prefab")).x;
5151
}
5252

53-
protected override void Export ()
53+
protected override bool Export ()
5454
{
55+
if (string.IsNullOrEmpty (m_exportFileName)) {
56+
Debug.LogError ("FbxExporter: Please specify an fbx filename");
57+
return false;
58+
}
59+
60+
if (string.IsNullOrEmpty (m_prefabFileName)) {
61+
Debug.LogError ("FbxExporter: Please specify a prefab filename");
62+
return false;
63+
}
64+
5565
var fbxDirPath = ExportSettings.GetFbxAbsoluteSavePath ();
5666
var fbxPath = System.IO.Path.Combine (fbxDirPath, m_exportFileName + ".fbx");
5767

@@ -60,26 +70,27 @@ protected override void Export ()
6070

6171
// check if file already exists, give a warning if it does
6272
if (!OverwriteExistingFile (fbxPath) || !OverwriteExistingFile (prefabPath)) {
63-
return;
73+
return false;
6474
}
6575

6676
if (m_toConvert == null) {
6777
Debug.LogError ("FbxExporter: missing object for conversion");
68-
return;
78+
return false;
6979
}
7080

7181
if (m_toConvert.Length == 1) {
7282
ConvertToModel.Convert (
7383
m_toConvert[0], fbxFullPath: fbxPath, prefabFullPath: prefabPath, exportOptions: ExportSettings.instance.convertToPrefabSettings.info
7484
);
75-
return;
85+
return true;
7686
}
7787

7888
foreach (var go in m_toConvert) {
7989
ConvertToModel.Convert (
8090
go, fbxDirectoryFullPath: fbxDirPath, prefabDirectoryFullPath: prefabDirPath, exportOptions: ExportSettings.instance.convertToPrefabSettings.info
8191
);
8292
}
93+
return true;
8394
}
8495

8596
protected override bool DisableNameSelection ()

Assets/FbxExporters/Editor/ExportModelEditorWindow.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void OnPresetSelectionChanged()
105105
this.Repaint ();
106106
}
107107

108-
protected abstract void Export ();
108+
protected abstract bool Export ();
109109

110110
/// <summary>
111111
/// Function to be used by derived classes to add custom UI between the file path selector and export options.
@@ -228,8 +228,9 @@ protected void OnGUI ()
228228
}
229229

230230
if (GUILayout.Button (ExportButtonName, GUILayout.Width(ExportButtonWidth))) {
231-
Export ();
232-
this.Close ();
231+
if (Export ()) {
232+
this.Close ();
233+
}
233234
}
234235
GUILayout.EndHorizontal ();
235236

@@ -347,12 +348,17 @@ protected override bool DisableNameSelection ()
347348
return m_isPlayableDirector;
348349
}
349350

350-
protected override void Export(){
351+
protected override bool Export(){
352+
if (string.IsNullOrEmpty (m_exportFileName)) {
353+
Debug.LogError ("FbxExporter: Please specify an fbx filename");
354+
return false;
355+
}
356+
351357
var folderPath = ExportSettings.GetFbxAbsoluteSavePath ();
352358
var filePath = System.IO.Path.Combine (folderPath, m_exportFileName + ".fbx");
353359

354360
if (!OverwriteExistingFile (filePath)) {
355-
return;
361+
return false;
356362
}
357363

358364
if (m_isPlayableDirector) {
@@ -366,14 +372,15 @@ protected override void Export(){
366372
// refresh the asset database so that the file appears in the
367373
// asset folder view.
368374
AssetDatabase.Refresh ();
369-
return;
375+
return true;
370376
}
371377

372378
if (ModelExporter.ExportObjects (filePath, m_toExport, ExportSettings.instance.exportModelSettings.info, timelineAnim: m_isTimelineAnim) != null) {
373379
// refresh the asset database so that the file appears in the
374380
// asset folder view.
375381
AssetDatabase.Refresh ();
376382
}
383+
return true;
377384
}
378385

379386
#if UNITY_2018_1_OR_NEWER

0 commit comments

Comments
 (0)