Can't slide horizontal slider

Hello,

I tried to make a horizontal slider (with C#). But when I run the game. I can't move the slider.

Anyone knows why that is? Code below:

float hSliderValue = 5.0f;

OnGUI {
Rect slider = new Rect (50, 30, 100, 30);
GUI.HorizontalSlider(slider,hSliderValue,1.0f,100.0f);
}

Hi, HorizontalSlider returns a value.

static function HorizontalSlider (position : Rect, value : float, leftValue : float, rightValue : float) : float

this should work:

float hSliderValue = 5.0f;

void OnGUI() {
      Rect slider = new Rect (50, 30, 100, 30);
      hSliderValue  = GUI.HorizontalSlider(slider,hSliderValue,1.0f,100.0f);
}

You need to feed the return value back into your variable:

float hSliderValue = 5.0f;

OnGUI {
    Rect slider = new Rect (50, 30, 100, 30);
    hSliderValue = GUI.HorizontalSlider(slider,hSliderValue,1.0f,100.0f);
}

A lot of the GUI controls work that way.

{
public float hSlideValue = 0.0f;

	void OnGUI()
	{    		
	  hSlideValue= GUI.HorizontalSlider(new Rect(25,25,100,30),hSlideValue,0.0f,10.0f);  		
	}   	
}

thnx … worked for me … was having the same problem