0
0
Unityframework~5 mins

DontDestroyOnLoad usage in Unity - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does DontDestroyOnLoad do in Unity?

DontDestroyOnLoad keeps a GameObject alive when loading a new scene. It prevents the object from being destroyed.

Click to reveal answer
beginner
How do you use DontDestroyOnLoad in a script?

Call DontDestroyOnLoad(gameObject); inside a script, usually in Awake() or Start() method.

Click to reveal answer
beginner
Why would you use DontDestroyOnLoad for a GameObject?

To keep important objects like managers, audio players, or player data alive across multiple scenes.

Click to reveal answer
intermediate
What happens if you use 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.

Click to reveal answer
intermediate
Can 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.

Click to reveal answer
What is the main purpose of DontDestroyOnLoad in Unity?
AKeep a GameObject alive between scene loads
BDestroy a GameObject immediately
CLoad a new scene asynchronously
DReset a GameObject's position
Where is the best place to call DontDestroyOnLoad(gameObject); in a script?
AInside <code>Awake()</code> or <code>Start()</code>
BInside <code>Update()</code>
CInside <code>OnDestroy()</code>
DInside <code>OnEnable()</code>
What problem can happen if you don't manage multiple instances of a DontDestroyOnLoad object?
AThe scene fails to load
BMultiple duplicates of the object appear
CThe object is destroyed immediately
DThe object loses its components
Can DontDestroyOnLoad be applied to a child GameObject directly?
AOnly if the child is active
BOnly if the child has a Rigidbody
CYes, any GameObject can be preserved
DNo, only root GameObjects can be preserved
Which of these is a common use case for DontDestroyOnLoad?
AChanging scene lighting settings
BResetting player position on scene load
CDestroying enemies when a scene loads
DKeeping a music player alive across scenes
Explain how and why you would use DontDestroyOnLoad in a Unity project.
Think about objects that should not reset when changing scenes.
You got /4 concepts.
    Describe a potential problem when using DontDestroyOnLoad without proper management and how to fix it.
    Consider what happens if multiple scenes create the same persistent object.
    You got /4 concepts.