Search Issue Tracker
Error when stopping Play Mode and setting parent of a transform to null in OnDestroy method
How to reproduce:
1. Open user attached project "New Unity Project.zip"
2. Open "SampleScene" scene
3. Enter Play Mode
4. Exit Play Mode
5. Observe Console Window
Expected result: No errors
Actual result: Error is thrown
Reproducible with - 2017.4.26f1, 2018.3.14f1, 2018.4.0f1, 2019.1.1f1, 2019.2.0a13, 2019.3.0a1
Error in 2018.3, 2018.4 and 2019.2 : NullReferenceException: Object reference not set to an instance of an object
NewBehaviourScript.OnDestroy () (at Assets/NewBehaviourScript.cs:10)
Error in 2017.4, 2019.1, and 2019.3: Can't destroy Transform component of 'Child'. If you want to destroy the game object, please call 'Destroy' on the game object instead. Destroying the transform component is not allowed.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- Reflection probe bounces don't work when Rendering Path is set to 'Deferred'
- Organizations are not displayed in the Services window
- Shader effect with specific view disappears when multiple materials in scene are present
- [Wild Crash] Editor crashes on mono_aot_get_cached_class_info when GizmoSetup has cached an outdated data
- [IMGUI] None,ScriptOnly and Full properties of stack trace are misaligned