Null reference in UnityEditor.Handles.DoPlanarHandle

I’ve got a project where my console gets spammed with the following every second or third time I press the play button:

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Handles.DoPlanarHandle (PlaneHandle planeID, Vector3 position, Quaternion rotation, Single handleSize) (at C:/buildslave/unity/build/Editor/Mono/EditorHandles/PositionHandle.cs:147)
UnityEditor.Handles.DoPositionHandle_Internal (Vector3 position, Quaternion rotation) (at C:/buildslave/unity/build/Editor/Mono/EditorHandles/PositionHandle.cs:90)
UnityEditor.Handles.DoPositionHandle (Vector3 position, Quaternion rotation) (at C:/buildslave/unity/build/Editor/Mono/EditorHandles/PositionHandle.cs:61)
UnityEditor.Handles.PositionHandle (Vector3 position, Quaternion rotation) (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorHandles.gen.cs:88)
UnityEditor.MoveTool.ToolGUI (UnityEditor.SceneView view, Vector3 handlePosition, Boolean isStatic) (at C:/buildslave/unity/build/Editor/Mono/GUI/Tools/BuiltinTools.cs:89)
UnityEditor.ManipulationTool.OnToolGUI (UnityEditor.SceneView view) (at C:/buildslave/unity/build/Editor/Mono/GUI/Tools/BuiltinTools.cs:19)
UnityEditor.MoveTool.OnGUI (UnityEditor.SceneView view) (at C:/buildslave/unity/build/Editor/Mono/GUI/Tools/BuiltinTools.cs:82)
UnityEditor.SceneView.DefaultHandles () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:1661)
UnityEditor.SceneView.OnGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:1191)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

You’ll notice that the entire stack trace is within Unity’s Editor. This is strange because a) it doesn’t happen all the time and b) a search for the error turned up nothing.

It’s not a showstopper, but it’s certainly a pain because it’s burying my own log messages.

This is in Unity 5.0.0f4. The project was started in 4.x and later upgraded to 5, though being an Editor issue I doubt that’s relevant. I am using editor extensions Editor Console Pr 2.51o and Graphical Analyzing Tool 1.2.3, though I believe I first saw this pop up before I started using them.

Any thoughts?

Wow. Now it freaks out and spams it if I so much as move the mouse in the Scene view, regardless of whether or not I’m in Play mode…

Edit: … or in fact anything that rases any kind of mouse event, by the looks of it. Like, clicking anything.

But now it’s stopped…

I also encounter this problem:

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Handles.DoPlanarHandle (PlaneHandle planeID, Vector3 position, Quaternion rotation, Single handleSize) (at C:/buildslave/unity/build/Editor/Mono/EditorHandles/PositionHandle.cs:147)
UnityEditor.Handles.DoPositionHandle_Internal (Vector3 position, Quaternion rotation) (at C:/buildslave/unity/build/Editor/Mono/EditorHandles/PositionHandle.cs:90)
UnityEditor.Handles.DoPositionHandle (Vector3 position, Quaternion rotation) (at C:/buildslave/unity/build/Editor/Mono/EditorHandles/PositionHandle.cs:61)
UnityEditor.Handles.PositionHandle (Vector3 position, Quaternion rotation) (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorHandles.gen.cs:88)
UnityEditor.MoveTool.ToolGUI (UnityEditor.SceneView view, Vector3 handlePosition, Boolean isStatic) (at C:/buildslave/unity/build/Editor/Mono/GUI/Tools/BuiltinTools.cs:89)
UnityEditor.ManipulationTool.OnToolGUI (UnityEditor.SceneView view) (at C:/buildslave/unity/build/Editor/Mono/GUI/Tools/BuiltinTools.cs:19)
UnityEditor.MoveTool.OnGUI (UnityEditor.SceneView view) (at C:/buildslave/unity/build/Editor/Mono/GUI/Tools/BuiltinTools.cs:82)
UnityEditor.SceneView.DefaultHandles () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:1661)
UnityEditor.SceneView.OnGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:1191)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

Yeah, I’m getting this exact error, and no idea as to why =/

For posterity’s sake, this error occurs when trying to use the Handles class outside of a OnSceneGUI function. The error is caused by the function call not having the appropriate id (“planeID” is this case). The IDs are supplied by the OnSceneGUI message.

9 Likes