脚本语言:C#

 

1、deltatime:

  deltatime它表示距上一次调用Update或FixedUpdate所用的时间,调用deltatime可以使物体的旋转以一种恒定的速度来运行,而不受帧速率的控制或计算机性能的影响。

 

2、time变量的使用:

  表示自游戏开始以来所经历的时间。

 

3、实例:

  创建一个脚本TimeShow,添加到主摄像机物体Main Camera中,脚本代码如下:

using UnityEngine;
using System.Collections;

public class TimeShow : MonoBehaviour {

    // Use this for initialization
    void Start () {
    }
    
    // Update is called once per frame
    void Update () {
    }

    void OnGUI(){
        GUILayout.Label ("当前时间是:"+Time.time);
        GUILayout.Label ("上一帧消耗的时间是:"+Time.deltaTime);
        GUILayout.Label ("固定增量时间是:"+Time.fixedTime);
        GUILayout.Label ("固定增量间隔时间是:"+Time.fixedDeltaTime);
        GUILayout.Label ("平滑DeltaTime:"+Time.smoothDeltaTime);
    }
}

可以看到时间类中的变量值在游戏窗中显示如下:

Unity Time的使用

 

相关文章:

  • 2021-05-13
  • 2021-06-27
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-14
  • 2021-10-19
猜你喜欢
  • 2021-08-01
  • 2021-12-19
  • 2022-12-23
  • 2022-01-03
  • 2021-11-27
  • 2021-09-26
相关资源
相似解决方案