Manual: Script Execution Order reference (original) (raw)

Quality settings tab reference

Use the Script Execution Order settings to specify the relative execution order of different MonoBehaviour script components in your project. The execution order between different scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary in the project is different from and doesn’t change the order of execution for event functions within each individual script. Unity always calls Awake before the first Update for each script, but you can configure script execution order to ensure that Awake for one script is always called before Awake for another. For example, if you have two scripts, EngineBehaviour and SteeringBehaviour, you can set the script execution order so that EngineBehaviour always updates before SteeringBehaviour.

Configuring execution order

To configure script execution order, go to: Edit > Project Settings, and then select the Script Execution Order category.

The Script Execution Order section of the Project Settings window displays a list of script classes and their currently configured execution order values.

The Script Execution Order section of the Project Settings window displays a list of script classes and their currently configured execution order values.

The integer values assigned to each script don’t represent any quantity but define each script’s execution order relative to the others. Unity executes scripts in order from lowest first to highest last, for example: –200, –100, –50, 50, 100, 200. The Editor stores these values in the script metadata files. You can leave gaps between the values to help avoid unnecessary file changes when you add or move other scripts in the list.

Unity executes any scripts not in the list during the Default Time slot, which occurs after any scripts with negative values and before any scripts with positive values.

Note: You can specify the script execution order from code rather than configuring it in the Editor by applying the [DefaultExecutionOrder] attribute to your MonoBehaviour-derived classes. For more information, refer to the [DefaultExecutionOrder] API reference.

Important considerations and limitations

Additional resources

Quality settings tab reference