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
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
Add comment