Highlighting GameObject materials on mouseover
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
Getting ready
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.
How to do it...
To highlight a material at mouseover, follow these steps:
- Create a new 3D project.
- Import the
border.png
image into your project. - Create a cube in the scene (GameObject | 3D Object | Cube).
- In the Project...