Version: Unity 6.0 (6000.0)
语言 : 中文
Managing update and 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 scripts, EngineBehaviour and SteeringBehaviour, you might want to ensure that EngineBehaviour always updates before SteeringBehaviour.

You can configure script execution order in the following ways:

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__(即用户界面,User Interface)让用户能够与您的应用程序进行交互。Unity 目前支持三种 UI 系统。更多信息
    See in Glossary
    .
  • 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__ GameObject__Unity 场景中的基础对象,可以表示角色、道具、风景、摄像机、路径点等。GameObject 的功能由所附的组件决定。更多信息
    See in Glossary
    they’re attached to.
  • When multiple scenes 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
事件函数