ClearPreviewCache error

I've just started getting the following error. I can correct it by deleting the Library folder of the project, but then it returns after a few plays in the editor. Is it me or is it a bug?

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.GameObjectInspector.ClearPreviewCache () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/GameObjectInspector.cs:211)
UnityEditor.GameObjectInspector.OnDisable () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/GameObjectInspector.cs:199)
UnityEditor.Rendering.LWRP.MaterialReimporter:ReimportAllMaterials()

Thanks

1 Like


There's not enough information here to answer that question. What changed in your project before this issue started to appear? Could you please submit a bug report with a (minimal) reproduction project?

I've just had this start occurring 100% of the time when I reload assemblies (i.e. any change to class files), and then invoke AssetDatabase.SaveAssets() during the reload callback (UnityEditor's EditorApplication.update)

I've submitted a bug report*: Case 1218243*

Seems to be that OnDisable's internal implementation crashes whenever OnDisable is called more than once in succession on the Unity internal class ... or: when OnDisable is called for a specific instance before OnEnable.

One of my guesses is that something in UnityEditor is cloning in-memory objects (part of the new prefab stuff? multi-scene eidting? Both of those do a clone/reload of all objects at some points) and then the newly cloned / reloaded object is getting OnDisable call that should have been routed to the original - so it doesn't have a valid internal cache (which is only created after a successful OnEnable call).

1 Like

[quote=“a436t4ataf”, post:3, topic: 751596]
I’ve just had this start occurring 100% of the time when I reload assemblies (i.e. any change to class files), and then invoke AssetDatabase.SaveAssets() during the reload callback (UnityEditor’s EditorApplication.update)

I’ve submitted a bug report**: Case 1218243**
[/quote]

This problem exists at least since 2019.2: https://discussions.unity.com/t/765814

[quote=“oscarAbraham”, post:4, topic: 751596]
This problem exists at least since 2019.2: https://discussions.unity.com/t/765814
[/quote]

In that linked thread, you’ll see I already posted it goes back at least as far as 2018.3 :slight_smile:

2 Likes

Happens several times a day here, 2018.4.9

Unity deleted my bug without looking at it, because 2018.4 was released.

So go ahead and re-log this bug, but please cite "Case 1218243" - which shows it was broken since at least 2018.3.