Displaying the value of an interactive UI Slider
This recipe illustrates how to create an interactive UI Slider, and execute a C# method each time the user changes the Slider value.
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 asslider value here
(this text will be replaced with the slider value when the scene starts). - In the Hierarchy panel, add a UI | Slider game object to the scene—choose the menu: GameObject | UI | Slider.
- In the Inspector tab, modify settings for the Rect Transform to position ...
Get Unity 5.x Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.