- Home /
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); }
Answer by Lloyd Hooson · Mar 30, 2010 at 12:14 PM
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); }
Answer by runevision · Mar 30, 2010 at 12:14 PM
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.
Answer by kevinspawner · Sep 05, 2013 at 06:26 AM
{
public float hSlideValue = 0.0f;
void OnGUI()
{
hSlideValue= GUI.HorizontalSlider(new Rect(25,25,100,30),hSlideValue,0.0f,10.0f);
}
}
Answer by parjanyaroy · Nov 23, 2012 at 07:12 AM
thnx .. worked for me .. was having the same problem
Your answer
Follow this Question
Related Questions
Curving an Horizontal Slider 2 Answers
HorizontalSlider? 1 Answer
How to make a Horizontal Slider slide between resolutions? 3 Answers
Horizontal Slider issue 0 Answers
move object with slider 1 Answer