Hi. I have a timer built and I have it setup to be a float number that gets displayed in a gui.
My problem is that the number (for example, 60) gets displayed as a number like 60.0000 and I don’t want that. I want to set up the gui to display only the integer and not the whole decimal number. How would you do that? :?
Thanks!
Hi. I have a timer built and I have it setup to be a float number that gets displayed in a gui.
My problem is that the number (for example, 60) gets displayed as a number like 60.0000 and I don’t want that. I want to set up the gui to display only the integer and not the whole decimal number. How would you do that? :?
Thanks!
var minsDisplay : int = _timer / 60;
var secondsDisplay : int = _timer % 60;
Then when displaying in the label or whatever use the formatting of ToString(…) to display them without decimal values, etc:
GUI.Label(myRect, minsDisplay.ToString("0") + ":" + secondsDisplay.ToString("00") );
And so on as needed.
-Jeremy
Thanks for that Jeremy!
For the record, all I needed was the ToString (“00”); class. Thanks, I didn’t know you could use it like that!
Yeah, figured I’d give you both, also for anyone else who “wandered by” later.
You can do a lot of other handy string formatting tricks with ToString(…) as well.
Here is a list of some of the built-in numeric formatters:
-Jeremy