Unity UI Slider
The Slider UI element is commonly used where a certain value should be set between a minimum and maximum value pair. One of the most common usages of this is for audio volume, screen brightness, or for doing zoom.
To create a slider UI, right-click on the scene hierarchy and select GameObject -> UI -> Slider. A new slider element will display on your scene.
Now, select the slider and go to the Inspector tab.
Let's try to make a volume slider. For this open the ButtonAction script which we previously created and did some changes on it:
Attach this script to the ButtonGameObject (which we previously created). Now, you will get a new slot for slider in the Inspector tab of ButtonGameObject.
Drag the slider from the Hierarchy tab to the newly created slot (My Slider) of ButtonGameObject.
Change the slider's maximum value to 100. And check mark for Whole Numbers.
Here, I changed the color of Text to green from its properties, so that it will be more visible.
Now press the play button and slide the slider.