- Home /
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
Answer by JeppeNygaard · Mar 22, 2013 at 08:51 AM
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
Answer by sparkzbarca · Mar 22, 2013 at 07:51 AM
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:
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 $$anonymous$$onoDevelop 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 !IsPlayingOrAllowInExecute$$anonymous$$ode which I just can't find what's causing it.
Your answer
Follow this Question
Related Questions
Null reference error after detecting collision 0 Answers
Attached scripts as List? 1 Answer
NullReferenceException script problem? 0 Answers
I'm having more problems accessing a variable from another script in c# 2 Answers
NullReferenceException 1 Answer