- Home /
Question by
espotori · Sep 10, 2014 at 01:58 PM ·
javascriptguilabel
Digit problem
Hello,
My problem is I am showing a float variable to the screen but it is showing it with digits (example: 123.05648) but I dont want to show digits. Only numbers(example: 123).
How can i do it? I am using simple GUI.Label for showing that variable.
GUI.Label(new Rect(15, 70, 300, 20), "Pizzas: " + PizzaAmount);
Comment
Best Answer
Answer by Landern · Sep 10, 2014 at 01:59 PM
Round the float to an int, the Mathf class can this for you:
GUI.Label(new Rect(15, 70, 300, 20), "Pizzas: " + Mathf.RoundToInt(PizzaAmount));
or you can cast it as an int, if you do that there is no rounding, just everything left of the decimal.
GUI.Label(new Rect(15, 70, 300, 20), "Pizzas: " + (int)PizzaAmount);