Limiting digits in GUI displayed variables (or "snap to" GUI slider).

I have a metronome controlled by a GUI slider in my game. I have then displayed the value of the slider variable using GUI.Label. This works great, only the variable often has way to many decimals (i want it to have none). So obscure values come up for the value. Is there a way to preferably create a "snap to" GUI slider or just limit the no. of decimals to be displayed on the label? Any help will be greatly appreciated. Oh and I used variable.ToString() for displaying the variable in the GUI.


will specify 0 decimal places or the string (F2 will be 2 decimal places, etc. in case you ever need to do that)

To answer your comment - if you want it to snap to every 5, in your specific case:


variable = (((int)(variable - 3)) / 5) * 5;


var temp : int = (variable - 3);
variable = (temp / 5) * 5;

Should do it