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?

thanks
Jeppe

2 Answers

2

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!

Jeppe

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

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

Thank you for your quick reply!! When I doubleclick the error, this shows up in the inspector: [9197-error.jpg|9197] I'm using a lot of scripts attached to elements bought in the AssetStore - I'm suspecting that this occurs in one of the many scripts, somehwere inside the asset-folder - a true needle/haystack issue. is there a way to locate this script? ... is it 100% sure that this IS indeed caused by a script? ... or can it be something else?

Does MonoDevelop not open too - when you double click?

no! ... and when I press "clear" in the console, the error appears on constant repeat again (like it's evaluating a script or an endless loop somewhere) ... any suggestions?

That particular error is internal, so it won't open a scripting window. It IS caused by a script (far as I know). I remember fixing this once by resetting Unity's window layout (which, I'm guessing, closed whatever of my special inspectors was malfunctioning). I think it can possibly also be caused by not closing all the closable GUI elements (BeginHorizontal, etc) in the Editor, and/or certain usage in the Scene GUI while not in play mode. It's a vague error with several possible causes :(

Yeah like !IsPlayingOrAllowInExecuteMode which I just can't find what's causing it.