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 ...

Get Unity UI Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.