How to change how meany decimals are in a GUI sound slider

 `
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.

Use standard .NET string formatting, such as volumeSliderS.ToString("f2") for 2 decimal places.

If you want to round to the 3rd decimal, use :

var roundedSome = Mathf.Round(volumeSliderS * 1000) / 1000;

If you want to round to the 5th decimal, use :

var roundedSome = Mathf.Round(volumeSliderS * 100000) / 100000;

You need to change the number of 0 accordingly to the number of decimals.