DontDestroyOnLoad do in Unity?DontDestroyOnLoad keeps a GameObject alive when loading a new scene. It prevents the object from being destroyed.
DontDestroyOnLoad in a script?Call DontDestroyOnLoad(gameObject); inside a script, usually in Awake() or Start() method.
DontDestroyOnLoad for a GameObject?To keep important objects like managers, audio players, or player data alive across multiple scenes.
DontDestroyOnLoad on multiple instances of the same GameObject?You may end up with duplicates in your game. Usually, you want to check and keep only one instance.
DontDestroyOnLoad be used on child GameObjects?Yes, it can be used on child GameObjects. It preserves the child and its descendants, detaching it from the parent if the parent is destroyed.
DontDestroyOnLoad in Unity?DontDestroyOnLoad keeps the GameObject alive when switching scenes.
DontDestroyOnLoad(gameObject); in a script?Calling it in Awake() or Start() ensures the object is preserved early.
DontDestroyOnLoad object?Without checks, duplicates accumulate, causing bugs or performance issues.
DontDestroyOnLoad be applied to a child GameObject directly?DontDestroyOnLoad works on any GameObject, including children. The child and its subtree are preserved and become roots in the DontDestroyOnLoad scene.
DontDestroyOnLoad?Music players or managers often use DontDestroyOnLoad to continue playing music seamlessly.
DontDestroyOnLoad in a Unity project.DontDestroyOnLoad without proper management and how to fix it.