why can’t i do this
var hSliderValue2:float;
function Update(){AudioListener.volume=hSliderValue2;}
function OnGUI () {GUI.Label (Rect (1000, 475, 100, 30), hSliderValue2*10 .ToString());
hSliderValue2 = GUI.HorizontalSlider (Rect (1000, 500, 160, 30), hSliderValue2, 0, 1);}
I want to have a GUI.Label there will display 5 if the hSliderValue2 = 0.5
system
2
well if thats the case then, you will just have to cast your output value into an int instead of a float to get a solid number.
try
(int)hSliderValue210 .ToString();
or (hSliderValue210 as int) .ToString();
i usually use c# so im not too familiar with javascript syntax
system
3
var hSliderValue2:float;
function Update(){AudioListener.volume=hSliderValue2;}
function OnGUI () {GUI.Label (Rect (1000, 475, 100, 30), (int)hSliderValue2*10 .ToString());
hSliderValue2 = GUI.HorizontalSlider (Rect (1000, 500, 160, 30), hSliderValue2, 0, 1);}
var hSliderValue2:float;
function Update(){AudioListener.volume=hSliderValue2;}
function OnGUI () {GUI.Label (Rect (1000, 475, 100, 30), (hSliderValue2*10 as int).ToString());
hSliderValue2 = GUI.HorizontalSlider (Rect (1000, 500, 160, 30), hSliderValue2, 0, 1);}
Try either one of those, see how i replaced the content parameter in the GUI.label, try that and see if it outputs a solid number
system
4
try using this:
var hSliderValue2:float;
var hsliderFullNumber:float;
function OnGUI () {
hsliderFullNumber= Mathf.Round(hSliderValue2*10);
GUI.Box (Rect (10, 10, 100, 30), hsliderFullNumber.ToString());
hSliderValue2 = GUI.HorizontalSlider (Rect (10, 500, 160, 30), hSliderValue2, 0, 1);
}