NullReferenceException UnityEditor.SerializedObject..ctor

Hello,

I keep getting the following error whenever I run my game:

NullReferenceException: (null)
UnityEditor.SerializedObject…ctor (UnityEngine.Object objs) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/SerializedPropertyBindings.cs:69)
UnityEditor.Editor.GetSerializedObjectInternal () (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/EditorBindings.cs:117)
UnityEditor.Editor.get_serializedObject () (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/EditorBindings.cs:110)
UnityEditor.MeshRendererEditor.OnEnable () (at C:/BuildAgent/work/d3d49558e4d408f4/Editor/Mono/Inspector/MeshRendererEditor.cs:16)

I consistently get 6 of them. The problem is that when I click it, it doesn’t take me to where in the script the error is so I have absolutely no clue how to debug this. I should mention that the game runs absolutely fine with the error, but I do not want this to cause any unexpected problem in the future.

How do I approach a problem like this?

Funny story… my Unity froze while I was trying to debug this, and when I restarted Unity the problem disappeared. So… I guess that’s the answer.

Changed “Mask” to “Rect Mask 2D”

Hate to necro this, but since it persists in 19.1.1f1:
The problem is, you’re previewing a Serialized object from your Project, in one (or both) of your Inspector windows. When you have 2 (or more) Inspector windows open while you preview a ScriptableObject Asset, you’ll get that error and be unable to compile. The reason why “it fixed itself” by restarting Unity is that your Windows Layout did not save, so you restarted with only 1 Inspector window open.

TLDR: Close any other Inspector Windows you have open while previewing a Serialized object asset. Make sure you have only 1 Inspector Window open, while previewing your SerializedObject Asset.

I’ve submitted a Bug Report to hopefully have this fixed in the future.

I still see the issue (Unity 5.6.0f3)…

My configuration…
94204-screen-shot-2017-05-16-at-145737.png

Repro steps…

  1. Create a configuration like in the second image (the material doesn’t matter actually)
  2. Run the game with the GameObject selected (it has to be selected before running the game)

Restarting the IDE makes it disappear but only until you select the GameObject again.

Note: The game works as expected. It’s just an annoying error message.

Best regards.