Script Execution Order Settings
脚本执行顺序设置
By default, the Awake, OnEnable and Update functions of different scripts are called in the order the scripts are loaded (which is arbitrary). However, it is possible to modify this order using the Script Execution Order settings (menu: Edit > Project Settings > Script Execution Order).
默认的,不同脚本的Awake, OnEnable 和 Update函数按脚本加载顺序(这是任意的)调用.然而,可以使用”脚本执行循序”来设置(菜单:编辑>项目设置>脚本执行顺序).
Scripts can be added to the inspector using the Plus “+” button and dragged to change their relative order. Note that it is possible to drag a script either above or below the Default Time bar; those above will execute ahead of the default time while those below will execute after. The ordering of scripts in the dialog from top to bottom determines their execution order. All scripts not in the dialog execute in the default time slot in arbitrary order.
脚本可以通过加号”+”键添加到检视面板并拖动以改变它们的相对顺序.注意:可以拖动一个脚本到”默认时间条”上面或下面;上面将在默认时间之前执行而下面将在默认时间之后执行.脚本在对话框中的顺序决定它们执行的顺序.所有不再此对话框内的脚本在默认时间内按任意顺序执行.
The numbers shown for each script are the values the scripts are actually ordered by. When a script is dragged to a new position, the number for the script is automatically changed accordingly. When a number is changed, either manually or automatically, it changes the meta file for that script. For this reason it’s best if as few of the numbers as possible change when the order is changed. This is why, when possible, only the script that is dragged has its number changed, rather than assigning new numbers to all the scripts.
显示在每个脚本上的数值是脚本当前的排序值.当脚本被拖动到一个新位置时脚本的数值也会相应的改变.当一个数值改变了,无论手动还是自动,它都改变了这个脚本的meta文件.由于这个原因当排序改变时这些数值越少改变越好.这是因为,在可能的情况下,拖动脚本只是改变数值,而不是指派一个新的数值给所有脚本.