Showing content from https://docs.unity3d.com/Manual/script-execution-order.html below:
Unity - Manual: Script execution order
Managing update and execution order
Event function execution order
Script execution order
In addition to the execution order of functions within scripts, another important consideration for your application is the order in which Unity executes different script components. For example, if you have two 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, EngineBehaviour
and SteeringBehaviour
, you might want to ensure that EngineBehaviour
always updates before SteeringBehaviour
.
You can configure script execution order in the following ways:
- In the Unity Editor, by using the Script Execution Order settings in the Project SettingsA broad collection of settings which allow you to configure how Physics, Audio, Networking, Graphics, Input and many other areas of your project behave. More info
See in Glossary window.
- In code, by applying the
[DefaultExecutionOrder]
attribute to your MonoBehaviour-derived classes.
Important considerations and limitations
- Execution order defined in code with
[DefaultExecutionOrder]
does not show in the Script Execution Order settings window. If you define an execution order for a MonoBehaviour-derived type in code with [DefaultExecutionOrder]
but define a different value for the same type in the Editorâs Project settings window, Unity uses the value defined in the Editor UI.
- If you assign multiple instances of the same scripts to different GameObjects, all instances of a script with a lower execution order value are executed before any instances of a script with a higher execution order value, regardless of which GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObjectâs functionality is defined by the Components attached to it. More info
See in Glossary theyâre attached to.
- When multiple scenesA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary are loaded additively, the configured script execution order is applied in full for one scene at a time rather than partially across scenes. In the previously cited example of an EngineBehaviour
script configured to execute before a SteeringBehaviour
script, both would update on one scene before they updated on the next one.
- When multiple scripts have either the same configured execution order or the default execution order, the order of execution between them is not deterministic. While the order might appear consistent during testing, you should never rely on this behavior, because it isnât guaranteed across builds, machines, or Unity versions. For more information, refer to Event function execution order.
- The execution order specified in the Script Execution Order settings window doesnât affect:
Additional resources
Managing update and execution order
Event function execution order
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4