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:
[DefaultExecutionOrder] attribute to your MonoBehaviour-derived classes.[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 系统。更多信息EngineBehaviour script configured to execute before a SteeringBehaviour script, both would update on one scene before they updated on the next one.[RuntimeInitializeOnLoadMethod] attribute.OnDisable and OnDestroy functions.