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
- The Decal Projector component Scene view editing tools are not visible in the Inspector window when Editor theme is set to Light
- An “Assertion failed on expression” error is thrown when building an AssetBundle and two assets have the same name
- Real delta time is different than deltaTime and uscaledDeltaTimeFixed when using multiple monitors with different refresh frequencies set in Windows options
- Persisted event listeners are reset when collapsing and expanding a component in the Inspector
- Floating Material Preview window has a burger icon button that does nothing when pressed
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.