Skip to content

Commit b9a8a19

Browse files
committed
fix errors when overwriting existing file
1 parent 46fac41 commit b9a8a19

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

Assets/FbxExporters/Editor/ConvertToPrefabEditorWindow.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@ protected override void Export ()
5353
var prefabPath = System.IO.Path.Combine (prefabDirPath, m_prefabFileName + ".prefab");
5454

5555
// check if file already exists, give a warning if it does
56-
CheckFileExists (fbxPath);
57-
CheckFileExists (prefabPath);
56+
if (!OverwriteExistingFile (fbxPath) || !OverwriteExistingFile (prefabPath)) {
57+
return;
58+
}
5859

5960
if (m_toConvert == null) {
6061
Debug.LogError ("FbxExporter: missing object for conversion");
62+
return;
6163
}
6264

6365
if (m_toConvert.Length == 1) {

Assets/FbxExporters/Editor/ExportModelEditorWindow.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,21 +238,26 @@ protected void OnGUI ()
238238
}
239239
}
240240

241-
protected void CheckFileExists(string filePath){
241+
/// <summary>
242+
/// Checks whether the file exists and if it does then asks if it should be overwritten.
243+
/// </summary>
244+
/// <returns><c>true</c>, if file should be overwritten, <c>false</c> otherwise.</returns>
245+
/// <param name="filePath">File path.</param>
246+
protected bool OverwriteExistingFile(string filePath){
242247
// check if file already exists, give a warning if it does
243248
if (System.IO.File.Exists (filePath)) {
244249
bool overwrite = UnityEditor.EditorUtility.DisplayDialog (
245250
string.Format("{0} Warning", ModelExporter.PACKAGE_UI_NAME),
246251
string.Format("File {0} already exists.", filePath),
247252
"Overwrite", "Cancel");
248253
if (!overwrite) {
249-
this.Close ();
250-
251254
if (GUI.changed) {
252255
SaveExportSettings ();
253256
}
257+
return false;
254258
}
255259
}
260+
return true;
256261
}
257262
}
258263

@@ -285,7 +290,9 @@ protected override void Export(){
285290

286291
filePath = System.IO.Path.Combine (filePath, m_exportFileName + ".fbx");
287292

288-
CheckFileExists (filePath);
293+
if (!OverwriteExistingFile (filePath)) {
294+
return;
295+
}
289296

290297
if (ModelExporter.ExportObjects (filePath, exportType: m_animExportType, lodExportType: ExportSettings.GetLODExportType()) != null) {
291298
// refresh the asset database so that the file appears in the

0 commit comments

Comments
 (0)