This recipe illustrates how to create an interactive UI Slider, and execute a C# method each time the user changes the UI Slider value:
Displaying the value of an interactive UI Slider
How to do it...
To create a UI Slider and display its value on the screen, follow these steps:
- Create a new 2D project.
- Add a UI Text GameObject to the scene with a Font size of 30 and placeholder text, such as slider value here (this text will be replaced with the slider value when the scene starts). Set Horizontal- and Vertical- Overflow to Overflow.
- In the Hierarchy add a UI Slider GameObject to the scene – choose menu: GameObject | UI | Slider.
- In the Inspector, modify the settings for the position of the UI Slider GameObject...