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
- Line Renderer Component elements do not fit in the Inspector window when minimising Inspector window is minimised
- “Do you want to apply changes?” warning pop-up appears when adding and removing list items in Player settings
- Line Renderer flickering in HDRP project when second Material field is set to None
- Texture 2D Importer fails to assing a default value to the "namefileidtable" when using a texture preset
- "ProcessRootMotion" method is called when "Apply Root Motion" is disabled in the Animator
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.