Mathf 常用方法
Mathf.Abs()------取绝对值
Mathf.Ceil()------向上取整,返回值为 Float 类型
Mathf.CeilToInt()------向上取整,返回值为 Int 类型
void Start()
{
//向上取整,返回比当前值大的一个整数
Debug.Log(Mathf.Ceil(10.0f));//10
Debug.Log(Mathf.Ceil(10.2f));//11
Debug.Log(Mathf.CeilToInt(10.7f));//11
Debug.Log(Mathf.Ceil(-10.0f));//-10
Debug.Log(Mathf.Ceil(-10.2f));//-10
Debug.Log(Mathf.CeilToInt(-10.7f));//-10
}
Mathf.Floor()--------向下取整,返回值为 Float 类型
Mathf.FloorToInt()--------向下取整,返回值为 Int 类型
void Start()
{
//向下取整,返回比当前值小的一个整数
Debug.Log(Mathf.Floor(10.0f));//10
Debug.Log(Mathf.