using System.Collections;
using System.Collections.Generic;
using UnityEngine;
///
///
///
public class TimeDemo : MonoBehaviour
{
public float speed = 50;
public void Update()
{
//每帧渲染 执行1次,旋转1度
//1秒旋转?度
//帧多,1秒旋转速度快,希望1帧旋转量小(Time.deltaTime)
//帧少,1秒旋转速度慢,希望1帧旋转量大
//unscaledDeltaTime 不受缩放时间影响
this.transform.Rotate(0, speed * Time.unscaledDeltaTime, 0);
//旋转速度 x 每帧消耗时间,可以保证旋转速度不受机器性能限制,以及渲染影响
}
//固定渲染,0.02s执行1次,与渲染无关,受timeScale的影响
/*public void FixedUpdate()
{
this.transform.Rotate(0, speed, 0);
}*/
//游戏暂停
private void OnGUI()
{
if(GUILayout.Button("the WORLD!"))
{
Time.timeScale = 0;
}
if (GUILayout.Button("the WORLD!"))
{
Time.timeScale = 1;
}
}
}
public class unscaledTimeDemo : MonoBehaviour
{
public float speed = 50;
public void FixedUpdate()
{
this.transform.Rotate(0, speed, 0);
}
}