Search Issue Tracker
Active
Votes
10
Found in
2017.4.0f1
2018.3.0a1
2018.3.11f1
2018.4.0f1
2019.1.0a1
2019.2.0a1
2019.3.0a1
Issue ID
1142531
Regression
No
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.
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
- Inconsistent behaviour when interacting with different dropdown types with pointer events on parent Visual Element
- Hidden GameObjects won't re-enable when they have call "DontDestroyOnLoad" function
- Overlay Canvas are rendered on each split-screen camera when HDR is enabled
- [Android] The Player loses focus when using UnityEngine.Handheld.StartActivityIndicator() with Facebook SDK
- Build fails with "Building Library/Bee/artifacts/MacStandalonePlayerBuildProgram/gahcy/hj9mx3z/951.0 failed with output:..." errors when Scripting Backend is set to IL2CPP
Turniper
Nov 17, 2020 02:00
I'm encountering this as well, in 2020.1 the use case is a script that detaches particles from the their emitters when the parent object is destroyed. It works fine in normal usage, allowing particle systems to play out their lifetimes organically after their emitter is destroyed, but it will throw this error when stopping the game in the editor. No real impact on usage, but tracking it down to this bug was a waste of an hour.
macube
Oct 21, 2020 20:27
The same on Unity 2019.4.9f1