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
- [OpenGLES][XR] Zooming in on the camera's URP opaque texture causes "double vision" on Quest in OpenGLES3
- “[Worker0] Could not generate preview image“ error when opening macOS native plugin in the Inspector with Architecture to build for set to ARM 64-bit
- [iOS] Application.absoluteURL is empty on Awake/Start when opening via deep link with Splash Screen disabled
- Crash on MemoryManager::Deallocate when rapidly calling Addressables.LoadAssetAsync
- Crash on physx::shdfnd::atomicIncrement when adjusting values on a character controller component after entering Play mode in Prefab edit mode
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.