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
- Crash on PrepareDrawShadowsCommandStep1 when entering the Play Mode in a specific project
- Physics Layer Collision Matrix's Layer names, checkboxes and hover highlights become misaligned when the Editor's UI Scaling gets changed
- Light/shadow information on an edge of a Terrain tile creates a seam with an adjacent Terrain tile when baking a LightMap
- "Missing types referenced from component UniversalRenderPipelineGlobalSettings on game object UniversalRenderPipelineGlobalSettings..." warning is thrown after switching the Platform to tvOS
- “Metal: Error creating pipeline state (Universal Render Pipeline/2D/Sprite-Lit-Default): Vertex attribute BLENDINDICES0(5) of type uint4 cannot be read using MTLAttributeFormatFloat2 (null)“ when setting GPU Skinning to GPU after opening the project
Add comment