Sample questions
Un Monobehaviour Lifecycle Execution OrderDifficulty 1
For a single script attached to a GameObject that is active when the scene loads, in which order does Unity call these three methods on it?
- aAwake, OnEnable, Start✓
- bOnEnable, Awake, Start
- cAwake, Start, OnEnable
- dStart, Awake, OnEnable
Explanation:Unity calls Awake first, then OnEnable, then Start, before the object's first Update.
Un Monobehaviour Lifecycle Execution OrderDifficulty 1
How many times does Unity call a script's Start method during that script instance's lifetime, assuming it is never destroyed and recreated?
- aOnce per frame
- bExactly once, for the instance's whole lifetime✓
- cEvery time the GameObject is disabled and re-enabled
- dOnce per scene load only if the object was created before the scene loaded
Explanation:Start runs exactly once for a script instance's lifetime, always after Awake.
Un Monobehaviour Lifecycle Execution OrderDifficulty 1
Which statement correctly distinguishes Update from FixedUpdate in Unity?
- aUpdate runs on a fixed physics timestep; FixedUpdate runs once per rendered frame
- bBoth run exactly once per rendered frame with no timing difference
- cUpdate runs once per rendered frame; FixedUpdate runs on a fixed timestep tied to physics✓
- dFixedUpdate only exists for UI code, physics uses Update
Explanation:Update is tied to the render frame rate; FixedUpdate runs on Unity's fixed timestep used for physics.
Un Monobehaviour Lifecycle Execution OrderDifficulty 1
What is true about LateUpdate relative to Update?
- aLateUpdate runs before all Update calls in the scene
- bLateUpdate replaces Update and only one of them can be used per script
- cLateUpdate runs at a fixed physics timestep like FixedUpdate
- dLateUpdate runs after that frame's Update calls have all finished✓
Explanation:LateUpdate is called once per frame, after every enabled script's Update has been called.
Un Monobehaviour Lifecycle Execution OrderDifficulty 2
A GameObject with a single script is disabled with SetActive(false) and then re-enabled with SetActive(true) later in the same scene. Which method runs again on that re-enable?
- aOnEnable✓
- bAwake
- cStart
- dNothing runs again
Explanation:OnEnable is called every time the object becomes active, unlike Awake and Start which are one-time calls.
Un Monobehaviour Lifecycle Execution OrderDifficulty 2
A GameObject is inactive in the Hierarchy when its scene loads. What happens to the Awake method of a script attached to it?
- aAwake runs immediately at scene load like on any other object
- bAwake is deferred until the object is first activated✓
- cAwake runs but OnEnable never will
- dAwake throws a runtime exception because the object is inactive
Explanation:Unity does not call Awake on a script attached to a GameObject that is inactive; the call is deferred until the object is first activated.