Creating a slider that changes colors gradually
Here, you are going to learn another type of customization that the player can perform at runtime. With this, the player has more power on how he can customize his own UI to fit suit his needs. In fact, the player will be able to switch between two colors, as in the previous chapter, but gradually and through a slider. We will handle this with a script and, as usual, using the events that are inside the Slider (Script) component.
How to do it...
First of all, we need to create our slider. This can be done easily by right-clicking on the Hierarchy panel, then going to UI | Slider, and renaming it to GraduallyColorSlider. Of course, it is possible to resize the slider, change Source Image, or change the text inside. Finally, place it as you wish, in Canvas.
Next, we can write a script to handle the entire process. To do this, select GraduallyColorSlider. In the Inspector, navigate to Add Component | New Script, rename it GraduallyColorSliderScript...