我正在尝试找到合适的词语来描述我遇到的问题,希望这能解释问题。
我在两个不同的类中有两个 Update() 方法,其中一个方法的某些功能依赖于另一个类的数据。代码A依赖于代码B的数据,使用Debug.Log()我发现代码B的Update()是在代码A的Update()<之后执行的/strong>.
我的问题是,是否有一个开箱即用的方法来控制 Update 方法的调用堆栈?如果有的话是怎么做到的?如果没有,是否有人有任何我可以用来解决问题的技术。我意识到我可以在代码 B 中创建可以从更新中的代码 A 调用的方法来解决问题,但我很好奇是否有其他方法可以解决问题。
最佳答案
来自 Unity 的 reference manual :
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.
这应该可以解决你的问题。
关于c# - Unity3D 中 Update() 循环方法内的执行顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22867935/