Discretized values for a HorizontalSlider GUI controller?

Hi!. I was wondering how to make that my HorizontalSlider has only 3 possible values along the bar. Something like converting the HorizontalSlider in a “Discretized HorizontalSlider” for having only 3 positions.

I have infinite values although I change the type of the value of the HorizontalSlider to integer.

Any idea?

As the docs state, the position of the slider is stored in a float, not an int.
You could round that float, like this (discrete slider 0-10):

var hSliderValue : float = 0.0;
var roundedValue : float;

function OnGUI () 
{
	hSliderValue = GUI.HorizontalSlider (Rect (25, 25, 100, 30), hSliderValue, 0.0, 10.0);
    if(GUI.changed==false && roundedValue != hSliderValue)
    {
         roundedValue = Mathf.Round(hSliderValue);
         hSliderValue = roundedValue;
    }
}

Problem solved: I did it ok, only that I missed the conversion before and after from float to integer respectively and from integer to float because I was modifying and working witha global variable whose type was float. Now it works. :wink: