O'Reilly logo

Unity UI Cookbook by Francesco Sapio

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding upper and lower bounds to the slider

Unity allows us to add lower and upper bounds to sliders in a very simple way. Inside the Slider (Script) component, there are two variables named Min Value and Max Value. If we take the slider from the previous recipe and change the values of these variables, we'll see that we can drag the handle of the slider to the end and the value has an upper bound, as we can see in the following screenshot:

Adding upper and lower bounds to the slider

In this recipe, we will write a script to block the handle of the slider as well in order to make the player perceive a real upper or lower bound.

How to do it...

  1. So that we don't recreate another slider, we can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required