
Unity Cookbook
By :

Changing the look or color of an object at runtime can be a very effective way of letting players know that they can interact with it. This is very useful in a number of game genres, such as puzzles and point-and-click adventures, and it can also be used to create 3D user interfaces.
In this recipe, we’ll swap materials when the mouse is over an object by using a second material, showing a border:
Figure 5.20: The interactive cube rollover highlight effect we’ll create in this recipe
For this recipe, you’ll need an image of a white square with a black border. We have provided such an image, called border.png
, in the 05_05
folder.
To highlight a material at mouseover, follow these steps:
border.png
image into your project.