Search Issue Tracker
By Design
Votes
0
Found in
2017.4
2019.3.0f6
2020.2
Issue ID
1216097
Regression
No
ArgumentNullException exception is thrown on _unity_self when using SerializedObject.targetObject inside a delegate
Reproduction steps:
1. Open the attached project ("case_1216097-PropDrawer.zip")
2. Open the repro scene ("SampleScene")
3. Select the "GameObject" object in Hierarchy
4. Deselect the object
5. Inspect Console
Expected result: No errors are thrown
Actual result: "ArgumentNullException: Value cannot be null." exception is thrown
Reproducible with: 2017.4.38f1, 2018.4.18f1, 2019.3.6f1, 2020.1.0b2, 2020.2.0a3
Note: On 2017.4 stream, "NullReferenceException: SerializedObject has been Disposed" exception is being thrown instead of "ArgumentNullException"
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
- Search window icons at the bottom are cut off when Search window is resized vertically
- "Try something else?" text label is cut off when searching for a long text in the Search window
- Rendering Debugger window sections do not have a minimum width set when resizing with the slider in the middle of the window
- Last segment of a Sprite Shape Spline is affected by other segments' Sprite Variant change when no edge Sprite is selected
- [iOS] Application frequently crashes on Social.LoadAchievements call when many achievements are registered
Resolution Note (2020.2.X):
This issue is expected because the serializedProperty is getting disposed of in the code to clean itself up after OnGUI. In such a case, it is expected that an ArgumentNullException is thrown because the PropertyAttribute getter returns a null value. In order to avoid this exception, it is required that the user adds a null check on the attribute in the OnGUI before using SerializedObject.targetObject.