Search Issue Tracker
Fixed in 2019.3.X
Votes
0
Found in
2019.3.0a1
2019.3.0a2
Issue ID
1161227
Regression
Yes
Crash on AssetDatabase::ReserializePrefabs when attempting to save a prefab at the same path as an existing folder (via Script)
How to reproduce:
1. Open attached project (Bug.zip)
2. Navigate to Test>Absolute Evil
3. Press Cancel
Reproducible with: 2019.3.0a1 2019.3.0a6
Not reproducible with: 2017.4.29f1, 2018.4.2f1, 2019.1.7f1, 2019.2.0b6
----
UPDATE:
The code that triggers the problem:
public static void SavePrefab1()
{
var path = "Assets/folder.prefab";
Directory.CreateDirectory(path);
PrefabUtility.SaveAsPrefabAsset(new GameObject(), path); //<- This causes save prefab to crash when the user clicks "Cancel" in the dialog that pops up
}
An alternative that handles the existence of files/directories:
public static void SavePrefab2()
{
var path = "Assets/folder.prefab";
Directory.CreateDirectory(path);
if (File.Exists(path))
{
if (EditorUtility.DisplayDialog("Saving new prefab", "There is already an asset at path '" + path + "', do you want to replace it?", "Yes", "No"))
{
File.Delete(path);
}
else
{
return;
}
}
if (Directory.Exists(path))
{
if (EditorUtility.DisplayDialog("Saving new prefab", "There is already a directory at path '" + path + "', do you want to replace it?", "Yes", "No"))
{
Directory.Delete(path, true);
}
else
{
return;
}
}
PrefabUtility.SaveAsPrefabAsset(new GameObject(), path);
}
This alternative is to be considered a workaround for now; the correct behavior is not defined at this point.
Fixed in: 2019.3.0a11
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Fixing Message Loss in UMPE During Domain Reload
- The Editor freezes when ScheduleReadOnly of IJobParallelForTransform with dependency is used
- Text is truncated in the Inspector when the display scale is set to 150%
- CancellationTokenSource(<timeout>) has incorrect cancellation status when used in WebGL Player
- VFX property value names are cut off when properties with 'Arc' are viewed in the VFX Blackboard
Add comment