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
- Fixing Message Loss in UMPE During Domain Reload
- The Editor freezes when ScheduleReadOnly of IJobParallelForTransform with dependency is used
- Text is truncated in the Inspector when the display scale is set to 150%
- CancellationTokenSource(<timeout>) has incorrect cancellation status when used in WebGL Player
- VFX property value names are cut off when properties with 'Arc' are viewed in the VFX Blackboard
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.