Unity3D高级手册04:更新指令(Update Order)

2014-08-16 12:26:36|?次阅读|上传:huigezrx【已有?条评论】发表评论

关键词:Unity3D, 游戏, 虚拟现实|来源:唯设编程网

Unity Manual > Advanced > Update Order

Unity手册->高级->更新指令

Update Order 更新指令

When you're keeping track of game logic and interactions, animations, camera positions, etc., there are a few different events you can use. The most common is to perform everything inside the Update() function. This is great for most kinds of operations, but there are other options!  

当你保持游戏逻辑和互动,动画,摄像机位置等,有几个不同的事件可以使用。最常见的是执行内部更新Update()函数。这对于大多数种类的运算是很大的,但也有其他的选择!

FixedUpdate 固定更新

FixedUpdate() is often called more frequently than Update(). It can be called multiple times per frame, if frame rate is low; and it can be not called between frames at all if frame rate is high. All Physics calculations and updates occur immediately before FixedUpdate(). When applying movement calculations inside FixedUpdate(), you do not need to multiply your values by Time.deltaTime. This is because FixedUpdate() is called on a reliable timer, independent of the frame rate.

FixedUpdate()通常调用的次数超过Update()。它可以被每帧多次调用,如果帧速率低,而且可以在帧与所有帧速是高之间不调用。所有的物理计算和更新发生FixedUpdate()之前。当内部FixedUpdate()的应用移动计算,你不需要你的值乘以Time.deltaTime。这是因为FixedUpdate()被称为一个可靠的计时器,不依赖与帧速率。

Update 更新

Update() is called once per frame. It is used far more commonly than any other option from a user perspective.

Update()是被每帧调用一次。它用于更为普遍比任何从用户的角度任何其它选择。

LateUpdate 最后更新

LateUpdate() is called once per frame, after Update() has finished. Any calculations that are performed in Update() will have completed when LateUpdate() begins. A common usage for LateUpdate() would be a following third-person camera. If you make your character move and turn inside Update(), you can perform all camera pointing and moving calculations in LateUpdate(). This will ensure that the character has moved completely before the camera tries to point itself at him.  

 LateUpdate()每帧调用一次,在Update()已经完成后。任何在最新的计算结果表明Update()将完成时LateUpdate()开始。一个LateUpdate()共同使用将是下面的第三人称摄像机。如果你把你的角色移动和转换成Update()内部,你可以执行所有的摄像机指向在LateUpdate()里移动计算。这将确保角色完全移动在摄像机尝试指定它自己之前。

Coroutine 协同

Coroutines are begun by using StartCoroutine(). Within the Coroutine, any time yield is called, the Coroutine will stop and resume where it left off after LateUpdate() has completed.

协同通过使用StartCoroutine()开始。在协同内部,任何时间段被调用,协同将停止并恢复在调用LateUpdate()已完成后它离开哪里。

发表评论0条 】
网友评论(共?条评论)..
Unity3D高级手册04:更新指令(Update Order)