Getting NullReferenceException error

I’m getting the following error multiple times in the inspector:

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.GameObjectInspector.OnDisable () (at <999cf70008af42ff801367fff45dedb1>:0)

And:

ArgumentNullException: Value cannot be null.
Parameter name: componentOrGameObject
UnityEditor.GameObjectInspector.OnEnable () (at <999cf70008af42ff801367fff45dedb1>:0)

I didn’t add any packages that would cause this and I don’t have an custom editor scripts or anything. What’s causing this error? It’s not halting my script execution as far as I can tell.

It only throws this error in play mode, but it’s an error with the editor? Very confused.

Nevermind, silly me. I restarted the editor and it’s fine now

2 Likes

Thanks for answering your own question.

I had this problem with the GameObjectInspector and another thread was saying it’s because the Inspector cannot refresh, often caused by pressing play whilst a scene object is selected.

This had me pulling my hair out for over an hour. In the end, I found you comment about restarting Unity and, although it should be an obvious thing to do, it hadn’t occured to me to do it because of the red herring thread.

Luckily I found your version of the solution and, I can confirm, it worked. No more GameObjectInspector exceptions.

Cheers MushyAvacado!!!

Yep, silly me, too.