how do I find what causes "NullReferenceException"

Hi all,

I’ve been reading about NullReferenceException in here and I think I have a better understanding of the problem now - BUT, I can’t find which script is causing the problem.

This is what I’m getting:

“NullReferenceException: Object reference not set to an instance of an object
UnityEditor.DockArea.OnGUI ()”

Does any know a good way to locate which script or part of my project that causes this error?


Thank you for all your answers.

I followed your advice Louis and tried to reset my editor layout back to factory default and sure enough there was an editor window that Unity wasn’t able to destroy :“DockArea” - I couldn’t see it and I don’t know what it is - but after re-setting the layout and re-starting unity - the error message disappeared! - thanks again!


double click on the error.

It means it appears unityeditor doesnt exist
most likely

basically your trying to call a function of an object. but the object doesnt exist.

your trying to call
but you dont have a gun for example

in that case your trying to call OnGUI()
but it doesnt exist probaly because
but DockArea doesnt exist
probably because unityeditor doesnt.