Making a button that changes color
In this recipe, we will see the first basic customization that we can allow the player to do. This customization will allow him to change the color of a button by clicking on it, and then switch between two colors. In this way, you will learn how it is possible to use events to customize buttons when the player interacts with them.
How to do it...
- In the first step, we have to create our UI button. Right-click on the Hierarchy panel, then go to UI | Button, and rename it to ChangeColorButton. Of course, it is possible to resize the button, change Source Image, the text, and place it as we wish in Canvas.
- Now, it's already time to write our script to handle the whole process. Select ChangeColorButton and, in the ...
Get Unity UI 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.