AssetDatabase.CreateAsset in PropertyDrawer OnGUI disposes SerializedObject!

Hi! In Unity 2020.2.6f1, 2020.2.7f1 this code (simplified version) will produce error:

NullReferenceException: SerializedObject of SerializedProperty has been Disposed.
UnityEditor.SerializedProperty.set_objectReferenceValue (UnityEngine.Object value) (at <8c48e4bc2ff34638b69095cbb65e2e27>:0)
Editor.PropertyDrawers.UniqueIdentifierDrawer.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at Assets/Editor/PropertyDrawers/UniqueIdentifierDrawer.cs:23)
UnityEditor.PropertyDrawer.OnGUISafe (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at <8c48e4bc2ff34638b69095cbb65e2e27>:0)
UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.Rect visibleArea) (at <8c48e4bc2ff34638b69095cbb65e2e27>:0)
UnityEditor.GenericInspector.OnOptimizedInspectorGUI (UnityEngine.Rect contentRect) (at <8c48e4bc2ff34638b69095cbb65e2e27>:0)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <420b942f64794d4da66420603f126f7b>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

In previous versions (for example 2020.2.4f1) all worked fine and we created assets without problems and assigned them to
SerializedProperty objectReferenceValue. Now it’s completely broken as calling AssetDatabase.CreateAsset just disposes SerializedObject.

1 Like

Case 1320367