@@ -383,6 +383,13 @@ public int ExportAll (IEnumerable<UnityEngine.Object> unityExportSet)
383
383
fbxScene . Destroy ( ) ;
384
384
fbxExporter . Destroy ( ) ;
385
385
386
+ if ( exportCancelled ) {
387
+ Debug . LogWarning ( "Export Cancelled" ) ;
388
+ // delete the file that got created
389
+ EditorApplication . update += DeleteFile ;
390
+ return 0 ;
391
+ }
392
+
386
393
return status == true ? NumNodes : 0 ;
387
394
}
388
395
}
@@ -394,14 +401,38 @@ public int ExportAll (IEnumerable<UnityEngine.Object> unityExportSet)
394
401
}
395
402
}
396
403
404
+ static bool exportCancelled = false ;
405
+
397
406
static bool ExportProgressCallback ( float percentage , string status ) {
398
407
// Convert from percentage to [0,1].
399
408
// Then convert from that to [0.5,1] because the first half of
400
409
// the progress bar was for creating the scene.
401
410
var progress01 = 0.5f * ( 1f + ( percentage / 100.0f ) ) ;
402
411
412
+ bool cancel = EditorUtility . DisplayCancelableProgressBar ( ProgressBarTitle , "Exporting Scene..." , progress01 ) ;
413
+
414
+ if ( cancel ) {
415
+ exportCancelled = true ;
416
+ }
417
+
403
418
// Unity says "true" for "cancel"; FBX wants "true" for "continue"
404
- return ! EditorUtility . DisplayCancelableProgressBar ( ProgressBarTitle , "Exporting Scene..." , progress01 ) ;
419
+ return ! cancel ;
420
+ }
421
+
422
+ static void DeleteFile ( )
423
+ {
424
+ if ( File . Exists ( LastFilePath ) ) {
425
+ try {
426
+ File . Delete ( LastFilePath ) ;
427
+ } catch ( IOException ) { }
428
+
429
+ if ( File . Exists ( LastFilePath ) ) {
430
+ Debug . LogWarning ( "Failed to delete file: " + LastFilePath ) ;
431
+ }
432
+ } else {
433
+ EditorApplication . update -= DeleteFile ;
434
+ AssetDatabase . Refresh ( ) ;
435
+ }
405
436
}
406
437
407
438
//
0 commit comments