Unity脚本执行顺序

来源:互联网 发布:上海菜鸟网络工资多少 编辑:程序博客网 时间:2024/04/27 19:52

初学Unity,对着Unity官方教程学习的时候,发现自己写的脚本执行顺序与示例不同。网上找了一些答案,没有找到为什么会这样。后来发现Unity官方对脚本运行顺序有说明:

By default, the Awake, OnEnable and Update functions of different scripts are called in the order the scripts are loaded (which is arbitrary).

意思大概是:不同脚本的Awake等函数的执行顺序是由脚本的加载顺序决定的。(加载顺序是随意的)


但是也可以手动修改这个执行顺序,(menu: Edit > Project Settings > Script Execution Order)

1 0