Search Issue Tracker
Fixed
Fixed in 2023.1.0a1
Votes
0
Found in
2022.1.2f1
2022.2.0a15
2023.1.0a1
Issue ID
UUM-658
Regression
No
NullReferenceException thrown when SerializedProperty.boxedValue is set to null
Reproduction steps:
1. Open the attached project "1420665.zip"
2. Select a GameObject in the Hierarchy window
3. Click "Example\\Log Property Values" in the menu bar
Expected result: No NullReferenceException thrown
Actual result: A NullReferenceException is thrown:
"NullReferenceException: Object reference not set to an instance of an object
UnityEditor.SerializedProperty.set_boxedValue (System.Object value) (at /Users/bokken/buildslave/unity/build/Editor/Mono/SerializedProperty.bindings.cs:373)
BoxedValueExample.LogValue (UnityEditor.SerializedProperty serializedProperty, System.Text.StringBuilder log) (at Assets/BoxedValueExample.cs:56)
BoxedValueExample.LogProperties (UnityEngine.Object obj, System.Text.StringBuilder log) (at Assets/BoxedValueExample.cs:40)
BoxedValueExample.MenuCallback () (at Assets/BoxedValueExample.cs:14)"
Reproducible with: 2022.1.2f1, 2022.2.0a15
Not reproducible with: 2019.4.39f1, 2020.3.35f1, 2021.3.3f1 (SerializedProperty does not have a boxedValue property)
Reproducible on: macOS 12.0.1
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- ScrollView speed is slower when entering Play mode
- UI Builder elements disappear and "Semantic - Unknown template name" error appears when changes to "Template" parameter are saved
- Renderers outside Light Probe hull use incorrect Ambient Probe values when "Renderer Light Probe Selection" is set to "Use Ambient Probe" and "Light Probes" on Mesh is set to "Blend Probes"
- ArgumentNullException error occurs when selecting a Camera in the Hierarchy with the Scene view open
- Clicking 'Open Editor Log' through the Console fails to open redirected Logs when relative Log files exist outside of the Project root
Resolution Note (fix version 2023.1.0a1):
This fix detect the null case in the boxedValue setter and throws an exception with clear error message rather than a the prior behaviour of throwing a general NullReferenceException.
The property types "ManagedReference", "ObjectReference" and "ExposedReference" can still be set to null because they are reference types.