四捨五入する方法を忘れやすいので自分用にメモ。
[ 方法 ]
下記はfloat型のFloatTestを四捨五入し、int型に変換しIntTestに代入しています。
using System; using System.Collections.Generic; using UnityEngine; public class ScriptTest : MonoBehaviour { void Start() { float FloatTest = 2.71828182845f; int IntTest = 0; IntTest = Mathf.RoundToInt(FloatTest); } }
2.71828182845を四捨五入すると3ですね。