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()
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).