999+ errors on compiling

Hello.

We’re having a relatively harmless, but annoying bug on our project. We’re having these two errors appearing multiples times every time our scripts recompiles. It goes away when we restart Unity.
The error appearance is not constant, as we can have multiples recompiles without it appearing, but as soon as it appears once, it will continue appearing, and the errors count will increase every time.

For exemple (I’ll take random numbers) :
I start up Unity, and just work as usual.
No errors appear until the 7th recompile. We then have ~40 of these errors.
At the 8th recompile, we have ~100 of these.
At the 9th, we have ~200
At the 10th, ~500
ect

We’re in Unity (2D) 2021.3.10f1, using URP.
We already tried :

  • Closing a potential second inspector window
  • Closing every single window
  • Removing every single asset
  • In an empty scene
  • “Reimport All”
  • Not having a GO selected in inspector

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.GameObjectInspector.OnDisable () (at <99feab6f3db6407493924fe4a179a95b>:0)
8538257--1140488--bug01.png

SerializedObjectNotCreatableException: Object at index 0 is null
UnityEditor.Editor.CreateSerializedObject () (at <99feab6f3db6407493924fe4a179a95b>:0)
UnityEditor.Editor.GetSerializedObjectInternal () (at <99feab6f3db6407493924fe4a179a95b>:0)
UnityEditor.Editor.get_serializedObject () (at <99feab6f3db6407493924fe4a179a95b>:0)
UnityEditor.GameObjectInspector.OnEnable () (at <99feab6f3db6407493924fe4a179a95b>:0)
8538257--1140491--bug02.png

Thanks for your time!

I’m not sure this is helpful, but I encountered a very similar behaviour with an editor window I was developing and which was embedding a GameObjectInspector: error start appearing at one point and error count keeps getting bigger with each recompile even when the window is closed.

I never managed to fix it (no amount of lifecycle management seemed to help) but you may want to search your codebase for Editor.CreateEditor to find culprits.

If you find a solution, please post it here, I’ll be interested as well :slight_smile:

1 Like

Sorry for the late replay, I wanted to make sure that the solution worked

We indeed had a script with Editor.CreateEditor, so we commented out the parts using that and the errors haven’t appeared since, we’ll just scrap the script and do without it.

Anyway, thanks a lot! You saved my hairs from being teared ahah