Time 类中封装了常用的时间控制方法 Mathf 类中封装了常用的数学方法 Time Mathf 代码实例 using UnityEngine; using System.Collections; public class Test : MonoBehaviour { public float angleSpeed; void Update () { if (Input.GetKeyDown(KeyCode.P)) { // Time 类用来进行时间控制 float t = Time.time; Debug.Log("从游戏开始当前帧,所消耗的总时长为:" + t + "秒"); // 从上一帧开始到当前帧结束,这两帧之间的时间间隔 float d = Time.deltaTime; Debug.Log(d); } // 让当前游戏对象每秒钟准确的旋转 30 度 transform.Rotate(Vector3.up, Time.deltaTime * angleSpeed ); // 表示时间流逝的快慢 // 1 - 表示时间正常流逝 // 2 - 表示时间流逝加快,是正常速度的两倍 // 0 - 表示时间停止,游戏停止 float ts = Time.timeScale; // 求绝对值 int i = Mathf.Abs(-12); // i = 12 // 求最大最小值 int max = Mathf.Max(12, 16, 48, 99, 3); int min = Mathf.Min(12, 16, 48, 99, 3); // 三角函数 //Mathf.Sin(); //Mathf.Cos(); //Mathf.PI; int s = Mathf.Sqrt(4); } }