2023.1.5f1 NullReferenceException: SerializedObject of SerializedProperty has been Disposed.

Still getting error NullReferenceException: SerializedObject of SerializedProperty has been Disposed.

This issue occurs when inspecting an object in the scene Heirarchy that has a script attached with an array list ( need to expand array list in inspector ). This issue has been going on for a few versions and hasnt been fixed. Very annoying issue… You will get thousands of these errors until you deselect the Heirarchy object with script that has the array list.

Edit: This issue can also happen sometimes with objects that dont have an array list

NullReferenceException: SerializedObject of SerializedProperty has been Disposed.
UnityEditor.SerializedProperty.get_objectReferenceInstanceIDValue () (at <8bcfff76472c48f096bf077900dc8a3a>:0)
UnityEditor.EditorGUIUtility.ObjectContent (UnityEngine.Object obj, System.Type type, UnityEditor.SerializedProperty property, UnityEditor.EditorGUI+ObjectFieldValidator validator) (at <8bcfff76472c48f096bf077900dc8a3a>:0)
UnityEditor.UIElements.ObjectField+ObjectFieldDisplay.Update () (at <8bcfff76472c48f096bf077900dc8a3a>:0)
UnityEditor.UIElements.ObjectField.UpdateDisplay () (at <8bcfff76472c48f096bf077900dc8a3a>:0)
UnityEngine.UIElements.VisualElement+SimpleScheduledItem.PerformTimerUpdate (UnityEngine.UIElements.TimerState state) (at :0)
UnityEngine.UIElements.TimerEventScheduler.UpdateScheduledEvents () (at :0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.UpdateSchedulers () (at :0)
UnityEngine.UIElements.UIEventRegistration.UpdateSchedulers () (at :0)
UnityEditor.RetainedMode.UpdateSchedulers () (at :0)

I recently ran into this issue and submitted a bug report for it. It is now on the issue tracker, so hopefully a fix is coming. I found this thread afterwards and wanted to drop a note to let you know.

Issue Tracker entry: Unity Issue Tracker - NullReferenceException is flooded when exiting Play Mode while Inspector is displaying a list whose contents are generated at runtime

2 Likes

At least im not the only one

There’s been thousands of threads with this same UIElements error.

It feels like UIElements isn’t really ready for “Prime time” yet.

Even the docs admit this: https://docs.unity3d.com/Manual/UIToolkits.html

“Unity intends for UI Toolkit to become the recommended UI system for new UI development projects, but it is still missing some features found in Unity UI (uGUI) and IMGUI.”

It appears one of those “missing features” might be the “NOT falling over itself with null reference errors” feature. :slight_smile:

It’s unfortunate because UnityEngine.UI works so well and has worked so well for ten years now, and yet we’re abandoning it all and it has now become Legacy, with nothing truly ready to replace it, alas.

This bug now appears to be fixed in the latest versions!

1 Like