在Unity3D的更新()循环方法中的执行顺序 [英] Execution order within the Update() loop method in Unity3D

查看:632
本文介绍了在Unity3D的更新()循环方法中的执行顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到合适的词用来描述我遇到的问题,希望这将说明这个问题。



我有两个更新()在两个不同的类,以及一些的功能的方法中一个是从另一个数据依赖。代码A是标准B的数据依赖,使用的debug.log()我发现,标准B的更新()正在代码A的更新后执行()



我的问题是,有没有开箱的方法来控制器更新方法的调用堆栈?如果有是怎么回事呢?如果没有,没有任何人有,我可以使用来解决问题的技术。我知道我可以创建标准B方法,可以从代码A的更新被调用来解决问题,但我很好奇,看看是否有另一种方式来解决这个问题。


< DIV CLASS =h2_lin>解决方案

从统一的参考手动




默认情况下,清醒,不同的脚本的OnEnable和更新函数被调用的顺序脚本加载(这是任意的)。但是,它是可以修改使用脚本执行命令设置此顺序。




这应该解决您的问题。


I'm trying to find the appropriate words to use to describe the issue that I am having, hopefully this will explain the problem.

I have two Update() methods in two different classes, and some of the functionality in one is reliant on data from another. Code A is reliant on Code B's data, using Debug.Log() I found that Code B's Update() is being executed after Code A's Update().

My question is, Is there a out of box method to controller the Call stack of the Update method? If there is how is it done? If there isn't, does anyone have any technique that I could employ to resolve the problem. I realize I could just create methods in Code B that could be called from Code A in update to resolve the problem, but I'm curious to see if there is another way to resolve the problem.

解决方案

From Unity's 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.

That should solve your problem.

这篇关于在Unity3D的更新()循环方法中的执行顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆