obsidian/笔记文件/2.笔记/Mathf.CeilToInt.md
2025-03-26 00:02:56 +08:00

645 B

#unity/日常积累

public static int CeilToInt (float f);

描述

返回大于或等于 f 的最小整数。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    void Start()
    {
        // Prints 10
        Debug.Log(Mathf.CeilToInt(10.0f));
        // Prints 11
        Debug.Log(Mathf.CeilToInt(10.2f));
        // Prints 11
        Debug.Log(Mathf.CeilToInt(10.7f));

        // Prints -10
        Debug.Log(Mathf.CeilToInt(-10.0f));
        // Prints -10
        Debug.Log(Mathf.CeilToInt(-10.2f));
        // Prints -10
        Debug.Log(Mathf.CeilToInt(-10.7f));
    }
}