Skip to content

Commit e88facf

Browse files
committed
refresh asset database in between deleting/copying
-Otherwise AssetDatabase tries to get the old (deleted) object and throws an error
1 parent 748c123 commit e88facf

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,9 @@ private void ReplaceFile ()
13181318
} catch (IOException) {
13191319
}
13201320

1321+
// refresh the database so Unity knows the file's been deleted
1322+
AssetDatabase.Refresh();
1323+
13211324
if (File.Exists (m_lastFilePath)) {
13221325
Debug.LogWarning ("Failed to delete file: " + m_lastFilePath);
13231326
}

Assets/FbxExporters/Editor/UnitTests/FbxPrefabTest.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,16 @@ public void TestTransformAndReparenting()
425425
var newCopyPath = ModelExporter.ExportObject(
426426
GetRandomFbxFilePath(), root);
427427
SleepForFileTimestamp();
428+
429+
var destFile = new FbxPrefabAutoUpdater.FbxPrefabUtility (original.GetComponent<FbxPrefab> ()).GetFbxAssetPath ();
430+
if (System.IO.File.Exists (destFile)) {
431+
System.IO.File.Delete (destFile);
432+
}
433+
AssetDatabase.Refresh ();
428434
System.IO.File.Copy(
429435
newCopyPath,
430-
new FbxPrefabAutoUpdater.FbxPrefabUtility(original.GetComponent<FbxPrefab>()).GetFbxAssetPath(),
431-
overwrite: true);
436+
destFile,
437+
overwrite: false);
432438
AssetDatabase.Refresh();
433439

434440
// Make sure the update took.

0 commit comments

Comments
 (0)