首页 > 其他 > 详细

time、deltaTime、fixedTime、fixedDeltatime的区别

时间:2017-01-09 23:39:46      阅读:488      评论:0      收藏:0      [点我收藏+]

time是从程序开始执行到现在的时间,deltaTime上一帧完成的时间,fixedTime表示FixedUpdate已经执行的时间,而fixedDeltatime是一个固定的时间增量。

在update()中time、deltaTime获取的是一个正确的值,fixedTime的值并不会增加,如果是在FixedUpdate

中,则fixedTime值会更新并且和time的值一样,deltaTime和fixedDeltatime的值一样。注意除了fixedDeltatime其他3个值都是只读的,可以通过fixedDeltatime来改变FixedUpdate的跟新速率。

void Update () {
        Debug.Log("在Update中执行");
        Debug.Log("time:"+Time.time);
        Debug.Log("deltatime"+Time.deltaTime);
        Debug.Log("fixedtime:"+Time.fixedTime);
        Debug.Log("fixedDeltatimetime:" + Time.fixedDeltaTime); 
}
    void FixedUpdate()
    {
        Debug.Log("在fixedUpdate中执行");
        Debug.Log("time:" + Time.time);
        Debug.Log("deltatime" + Time.deltaTime);
        Debug.Log("fixedtime:" + Time.fixedTime);
        Debug.Log("fixedDeltatimetime:" + Time.fixedDeltaTime); 
    }

time、deltaTime、fixedTime、fixedDeltatime的区别

原文:http://www.cnblogs.com/wanggang550/p/6266802.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!