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
- [Dragon Crashers] Build fails in U6
- [Dragon Crashers] 4 Shader error messages on import
- [Dragon Crashers] Readme text is white on light grey
- Cursor stays in front of the first character when entering text in the TextMeshPro field
- Searching in Hierarchy causes unwanted component calls
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.