NullReferenceException when attempting to select Rectangles that have been disabled since game start

Avatar
  • updated
  • Fixed

I have Rectangle components attached to children of a prefab that I am instantiating copies of. The Rectangles' parent GameObjects are disabled by default. When I select them in the Hierarchy during Play Mode, I get the following error:

NullReferenceException: Object reference not set to an instance of an object
Shapes.RectangleEditor.OnInspectorGUI () (at Assets/Shapes/Scripts/Editor/Components/RectangleEditor.cs:64)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.b__0 () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorElement.cs:538)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)


It doesn't seem like this actually breaks anything; I was able to re-enable the rectangles and they render as expected.

Reporting a bug? please specify Unity version:
Unity 2020.1.2f1
Reporting a bug? please specify Shapes version:
2.3.1
Reporting a bug? please specify Render Pipeline:
Pinned replies
Avatar
Freya Holmér creator
  • Answer
  • Fixed

ah, got a repro! this has now been fixed in 3.2.1

Avatar
Malcolm Anderson

I realized that I wasn't on the latest version of Shapes, so I just updated to v2.3.2. I'm now getting a different error:

NullReferenceException: Object reference not set to an instance of an object
Shapes.ShapeRenderer.HideMeshFilterRenderer () (at Assets/Shapes/Scripts/Runtime/Components/ShapeRenderer.cs:103)
Shapes.ShapeRendererEditor.OnEnable () (at Assets/Shapes/Scripts/Editor/Components/ShapeRendererEditor.cs:81)
Shapes.RectangleEditor.OnEnable () (at Assets/Shapes/Scripts/Editor/Components/RectangleEditor.cs:24)

Avatar
Freya Holmér creator

does this still happen for you? I'm pretty sure this has been fixed a while back from fixing separate issues

Avatar
Malcolm Anderson
Quote from Freya Holmér

does this still happen for you? I'm pretty sure this has been fixed a while back from fixing separate issues

Tested it again with Shapes 3.2.0 on Unity 2020.1.2f1 and got the errors again

NullReferenceException: Object reference not set to an instance of an object
Shapes.ShapeRenderer.HideMeshFilterRenderer () (at Assets/Shapes/Scripts/Runtime/Components/ShapeRenderer.cs:187)
Shapes.ShapeRendererEditor.OnEnable () (at Assets/Shapes/Scripts/Editor/Components/ShapeRendererEditor.cs:96)
Shapes.RectangleEditor.OnEnable () (at Assets/Shapes/Scripts/Editor/Components/RectangleEditor.cs:28)

And then, repeated 6 times:

NullReferenceException: Object reference not set to an instance of an object
Shapes.RectangleEditor.OnInspectorGUI () (at Assets/Shapes/Scripts/Editor/Components/RectangleEditor.cs:71)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.b__0 () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorElement.cs:538)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)

Avatar
Freya Holmér creator
  • Answer
  • Fixed

ah, got a repro! this has now been fixed in 3.2.1