- Home /
How to change how meany decimals are in a GUI sound slider
Code:
static var volumeSliderS = 1.0;
function OnGUI() {
volumeSliderS = GUI.HorizontalSlider (Rect(480, 130, 100, 30), volumeSliderS, 0.0, 1.0);
GUI.Label(Rect(480,105,200,30),"Music = "+volumeSliderS);
}
What I was wondering is how to change how meany decimals are in a GUI slider? When I play the game it is so long that it goes into my GUI.label
and it is frustrating and don't know how to fix it.. My game is done its just I have been trying to find how to do this.
Answer by iwaldrop · Jul 03, 2013 at 07:41 PM
You need to specify how many numeric decimal places you want to use. I'm a C# guy so I don't know if this will work in UnityScript, but try it and let me know.
C# Standard Numeric Format Strings
function OnGUI() {
volumeSliderS = GUI.HorizontalSlider (Rect(480, 130, 100, 30), volumeSliderS.ToString("N1"), 0.0, 1.0);
GUI.Label(Rect(480,105,200,30),"Music = "+volumeSliderS);
}
Assets/$$anonymous$$enuScript.js(437,46): BCE0023: No appropriate version of 'UnityEngine.GUI.HorizontalSlider' for the argument list '(UnityEngine.Rect, String, float, float)' was found.