To highlight a material at mouseover, follow these steps:
- Create a new 3D project.
- Import the border.png image into your project.
- Create a 3D Cube in the scene (Create | 3D Object | Cube).
- In the Project window, create a new Material asset named m_cube. Set its Albedo color to red.
- Duplicate your material, naming the copy m_cubeHighlighed. Set the Albedo image for this new material to border:
Figure 5.18 – Assigning the border image to the Albedo texture
- In the Hierarchy window, select the Cube GameObject and assign it m_cube Material. To do so, drag the asset file from the Project window onto the GameObject.
- Create a new C# script class called MouseOverSwap and add an instance object as a component to the cube:
using UnityEngine;
public class MouseOverSwap : MonoBehaviour
{
public Material mouseOverMaterial;
private Material _originalMaterial;
private...