sev*_*ine 2 algorithm unity-game-engine
我对Mathf.RoundToInt()有疑问
int val = Mathf.RoundToInt(10.5f);
val = Mathf.RoundToInt(9.5f);
val = Mathf.RoundToInt(8.5f);
Run Code Online (Sandbox Code Playgroud)
以上产生"10,10,8"而不是"11,10,9".
根据Unity的参考手册,当第一个小数位为"5"(例如8.5 - > 8.0)时,Mathf.RoundToInt()返回"偶数值".
我想知道Mathf.RoundToInto()返回的原因,不像普通的舍入(例如8.5 - > 9.0,9.5 - > 10.0).