Search Issue Tracker
Won't Fix
Votes
0
Found in
2018.4
2019.4
2020.3
2021.1
2021.1.3f1
2021.2
Issue ID
1337272
Regression
No
SetParent does not work OnDestroy() when new parent is in DontDestroyOnLoad scene
Reproduction steps:
1. Open attached project "Reparent.zip" and scene "SampleScene"
2. Enter Play Mode
3. After waiting 5 seconds, In Hierarchy window, observe DontDestroyOnLoad scene's "Global" GameObject
Expected result: The "Global" GameObject has two children
Actual result: The "Global" GameObject has no children
Reproducible with: 2018.4.35f1, 2019.4.28f1, 2020.3.11f1, 2021.1.9f1, 2021.2.0a19
Notes:
1. Issue does not reproduce when reparenting to DontDestroyOnLoad scene without OnDestroy()
2. Issue does not reproduce when reparenting in the same scene with OnDestroy()
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
- Rendering Debugger Playmode debug UI scrolling is jittery when using click and drag to scroll
- Frame Debugger Target Selection Search Results window becomes too tiny to even see the default “Editor” selection when there are no search results
- Element name field has no character limit in UI Builder
- Async method in Play Mode being aborted when calling `new System.Windows.Forms.Form`
- Animator window Eye button on click visual does not cover the whole area of the button when clicked
Resolution Note:
After calling LoadScene it's not possible to try and avoid the deletion of the objects, once you get OnDestroy you can’t prevent destruction of the object. Before calling LoadScene you need to re-parent the objects you don't wish to be deleted.