
How it works...
You created a UI Slider GameObject, and set it to be whole numbers in the range of 0 ... 20.
You have added an instance of the SliderValueToText C# script class to the UI Text GameObject.
The Awake() method caches references to the Text component in the textSliderValue variable.
The Start() method invokes the ShowSliderValue() method, so that the display is correct when the scene begins (that is, the initial slider value is displayed).
The ShowSliderValue() method gets the value of the slider and then updates the text displayed to be a message in the form of Slider value = <n>.
You added the ShowSliderValue() method of the SliderValueToText scripted component to the Slider GameObject's list of On Value Changed event listeners. So, each time the slider value changes, it sends a message to call the ShowSliderValue() method, and so the new value is updated on the screen.