Skip to content

Instantly share code, notes, and snippets.

@todorok1
Last active Jul 3, 2018
Embed
What would you like to do?
MathfのRoundを使った時の動作
void RoundTest(){
float value = 3.15f;
Debug.Log("value : " + value + " / Round : " + Mathf.Round(value));
Debug.Log("value : " + value + " / RoundToInt : " + Mathf.RoundToInt(value));
value = -9.61f;
Debug.Log("value : " + value + " / Round : " + Mathf.Round(value));
Debug.Log("value : " + value + " / RoundToInt : " + Mathf.RoundToInt(value));
value = 2.51f;
Debug.Log("value : " + value + " / Round : " + Mathf.Round(value));
value = 3.5f;
Debug.Log("value : " + value + " / Round : " + Mathf.Round(value));
value = 4.5f;
Debug.Log("value : " + value + " / Round : " + Mathf.Round(value));
value = 5.5f;
Debug.Log("value : " + value + " / Round : " + Mathf.Round(value));
float roundedValue = Mathf.Round(value);
// 明示的にキャストが必要
int roundedIntValue = (int) Mathf.Round(value);
float roundedToIntValueToFloat = Mathf.RoundToInt(value);
int roundedToIntValueToInt = Mathf.RoundToInt(value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment