x


Displaying the Value on a Horizontal Slider

I want to make a slider that has integer values between 0 and 90 inclusive. However, when i run this in my project, the word Angle along with the slider only appear. How can i display the value of the number between 0 and 90 right next to the slider?

function OnGUI () { mySlider = LabelSlider (Rect (10, 100, 100, 20), mySlider, 5.0, "Angle"); }

function LabelSlider (screenRect : Rect, sliderValue : float, sliderMaxValue : float, labelText : String) : float { GUI.Label (screenRect, labelText); screenRect.x += screenRect.width; // <- Push the Slider to the end of the Label sliderValue = GUI.HorizontalSlider (screenRect, sliderValue, 0.0, sliderMaxValue); return sliderValue; }

more ▼

asked May 30 '11 at 03:34 PM

thatbigguy gravatar image

thatbigguy
1 5 5 5

(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

mySlider = LabelSlider (Rect (10, 100, 100, 20), mySlider, 5.0, "Angle");

The very last variable is the string you want to display. Replace it by "Angle"+mySlider to add the value of the slider to it.

mySlider = LabelSlider (Rect (10, 100, 100, 20), mySlider, 5.0, "Angle "+mySlider);

more ▼

answered May 30 '11 at 03:36 PM

Joshua gravatar image

Joshua
6.5k 19 25 72

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x126
x109

asked: May 30 '11 at 03:34 PM

Seen: 998 times

Last Updated: May 30 '11 at 03:36 PM