Skip to content

Commit fcdbe0a

Browse files
Fix rare and strange edge case that can cause GUIDs to fail to save
I detect when a guid is getting created for a Prefab Instance and guarantee that we call RecordPrefabInstanceModifications even if the prefab parent is invalid.
1 parent e71da54 commit fcdbe0a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Assets/CrossSceneReference/GuidComponent.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ void CreateGuid()
2929
{
3030
guid = System.Guid.NewGuid();
3131
serializedGuid = guid.ToByteArray();
32+
33+
if UNITY_EDITOR
34+
// If we are creating a new GUID for a prefab instance of a prefab, but we have somehow lost our prefab connection
35+
// force a save of the modified prefab instance properties
36+
PrefabType prefabType = PrefabUtility.GetPrefabType(this);
37+
if (prefabType == PrefabType.PrefabInstance)
38+
{
39+
PrefabUtility.RecordPrefabInstancePropertyModifications(this);
40+
}
41+
#endif
3242
}
3343
else if (guid == System.Guid.Empty)
3444
{

0 commit comments

Comments
 (0)