2018年了,新年老是会制定不少具体目标和计划,无论可否坚持去完成,初衷和决心老是要有的。本年第一篇博客终于开始下笔了,先立一些今年和公司业务无关的的flag:html
官方API https://docs.unity3d.com/ScriptReference/Time.htmlless
Time.deltaTime(只读)ide
unity官方解释为:函数
The time in seconds it took to complete the last frame (Read Only).性能
以秒计算,完成最后一帧的时间(只读)。ui
Use this function to make your game frame rate independent. this
使用这个函数使和你的游戏帧速率无关。spa
一句话总结:指的是当前时间节点的上一帧所用的时间。3d
void Update () { //方式1 // gameObject.transform.Translate(new Vector3(0,0,10)); //方式2 gameObject.transform.Translate (new Vector3 (0, 0, 10) * Time.deltaTime); }
方式1 表示 : Update函数每帧调用一次,也便是说每一帧物体都会向前移动10m,不能保证匀速,由于每一帧的时间间隔不必定相同code
方式2表示 : 执行当前帧的时候移动前一帧所用的时间*10m,从第二帧开始以10m/s的速度移动。
Time.time(只读)
unity官方解释为:
The time at the beginning of this frame (Read Only). This is the time in seconds since the start of the game.
此帧开始时的时间(只读)。这是游戏开始后以秒为单位的时间。
Returns the same value if called multiple times in a single frame. When called from inside MonoBehaviour's FixedUpdate, returns fixedTime property.
若是在同一帧中屡次调用,则返回相同的值。当在MonoBehaviour的FixedUpdate中调用,返回固定时间。
Time.fixedTime(只读)
The time the latest FixedUpdate has started (Read Only). This is the time in seconds since the start of the game.
最近的FixedUpdate帧开始的时间(只读)。这是游戏开始后以秒为单位的时间。
Fixed time is updated in regular intervals (equal to fixedDeltaTime) until time property is reached.
当知足时间性能时,固定时间会按期更新(至关于fixeddeltatime)。
Time.timeScale(可写)
Time.timeScale影响的是Unity的游戏时间缩放比例.
记住下面两句话:
1.“timeScale不会影响Update和LateUpdate的执行速度”
2.“FixedUpdate是根据时间来的,因此timeScale只会影响FixedUpdate的速度”。
官方的一句话:
Except for realtimeSinceStartup, timeScale
affects all the time and delta time measuring variables of the Time class.
除了realtimesincestartup,timeScale影响Time类中全部时间和时间增量测量相关的变量。
Time.captureFramerate(可写)
unity官方解释为:
Slows game playback time to allow screenshots to be saved between frames.
减慢游戏播放时间,容许帧与帧之间截图。
If this property has a non-zero value then frame update will occur at an interval of (1.0 / captureFramerate) regardless of real time and the time required to render a frame.
若是这个属性有一个非零的值,而后架更新将发生在一个区间(1 / captureframerate)不管实时渲染一帧所须要的时间。
一句话总结:设置游戏帧速率。