" NullReferenceException: Object reference not set to an instance of an object"

Please help me. Do you know why I’m receiving this message meanwhile I’m testing my game?.

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.ListViewShared.HasMouseDown (UnityEditor.InternalListViewState ilvState,
Rect r, Int32 button) (at C:/BuildAgent/work/6bc5f79e0a4296d6/Editor/Mono/GUI/ListViewShared.cs:180)
UnityEditor.ListViewShared.HasMouseDown (UnityEditor.InternalListViewState ilvState, Rect r) (at C:/BuildAgent/work/6bc5f79e0a4296d6/Editor/Mono/GUI/ListViewShared.cs:175)
UnityEditor.ListViewShared+ListViewElementsEnumerator.MoveNext () (at C:/BuildAgent/work/6bc5f79e0a4296d6/Editor/Mono/GUI/ListViewShared.cs:368)
UnityEditor.ConsoleWindow.OnGUI () (at C:/BuildAgent/work/6bc5f79e0a4296d6/Editor/Mono/ConsoleWindow.cs:422)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object parameters, System.Globalization.CultureInfo culture)

Thank you very much.

It means that an object is referenced somewhere in the code but the game cant find that gameobject since it returns null which is the indication that it does not exist , which means that you either had a GameObject or Behaviour variable and you did not get to define the object or behaviour you want it to reference in the inspector. Alternatively , GameObject.Find functions return a nullreference exception if you try to access something from a found gameobject , but the game does not actually find it. So if you dont have for example a gameobject named foo , GameObject.Find("foo").bar=3; would return a nullreferenceexception due to the fact that the variable bar does not exist in the inexistent gameobject.

You ought to provide us with the code that produces the error for more specific information though

This problems doesnt have to do with the project itself, but something with Unity/Visual Studio/Monodevelop.

I have the same issue, after having just started a fresh project and:

  1. pressing “sync monodevelop project” since the thing still wont recognize I’m using VS
  2. opening the project in the unity project folder so i can get proper references
  3. building a simple script
  4. fixing the incorrect “line endings” on the script to windows format

I think it has something to do with trying to reference something from monodevelop, for some reason.

I solved my issue a week ago. I’m a newbye and sometimes I don’t know how to understand those debugging messages.

But thank you anyway. :slight_smile: