Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Managing update and execution order

Understand the order in which Unity executes your script components and the lifecycle callbacks within those scripts during the runtime application loop.
Read time 1 minuteLast updated 7 days ago

Unity runtime applications run in a loop, where the engine repeatedly processes input, updates game state, and renders frames. This is commonly called the game or Player loop. Traditional component-based Unity projects use MonoBehaviour script components to hook into the Player loop through a series of built-in callbacks called event functions, which provide the opportunity to update your GameObjects every frame, or in response to specific events.
Knowing the execution order can help you customize and optimize your project. For example, you might need to ensure some setup work always happens before the first frame update, or that scripts controlling the engine of a vehicle always run before those that control its steering.

Topic

Description

Script execution orderUnderstand how Unity prioritizes execution of individual MonoBehaviour scripts.
Event functionsEvent functions are a set of built-in callbacks which you can implement on your MonoBehaviour-derived scripts to respond to core Engine events related to physics, rendering, input, scene loading, and object lifecycles.
Event function execution orderUnderstand the execution order of Unity's built-in event functions so you can respond to events and update the state of your game in the right order.
Customizing the Player loopCustomize the Player loop to change the order in which Unity updates systems in each iteration of the loop.
Using a custom update managerCreate an update manager to handle many per-frame updates.
Inspector-configurable custom eventsCreate your own custom events to configure persistent (lasting between Edit mode and Play mode) callbacks in the Inspector window.

Additional resources