Search Issue Tracker
By Design
Votes
1
Found in
2019.2.17f1
2019.3
2020.2
Issue ID
1224308
Regression
No
NullReferenceException error is thrown to the Console when DestroyImmediate method is used
How to reproduce:
1. Open user's attached 'CustomPreviewBug.zip' project
2. Open 'SampleScene' Scene
3. Select 'Cube' GameObject in the Hierarchy
4. Enter Play Mode
Expected result: No errors thrown to the Console
Actual result: 'NullReferenceExceptionError' error is thrown to the Console
Reproducible with: 2019.3.5f1, 2020.1.0b1, 2020.2.0a2
Could not test with: 2017.4.38f1, 2018.4.19f1 because multi-object editing is not supported
Notes:
- Video of reproduction attached in Edit
- Reproducible on macOS
- If unable to reproduce the issue when entering Play Mode try to exit and enter the Play Mode for a few more times
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
- Foldout arrow indent is misaligned in the Inspector when used in Custom Type
- [Android] The Player screen turns black when playing a video under certain conditions
- 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
Resolution Note:
Post from https://docs.unity3d.com/ScriptReference/Object.DestroyImmediate.html
This function should only be used when writing editor code since the delayed destruction will never be invoked in edit mode. In game code you should use Object.Destroy instead.
If the code should be executed in both edit- and playmode, you can use defines to change when you call which method.