I’m trying to change the two materials of my object when the mouse hovers over it, and then change them back once the mouse stops hovering over it. Absolutely nothing happens when I play the game so help would be nice. My code is here:
using UnityEngine;
public class Build : MonoBehaviour
{
public Material hoverColorGrass;
public Material hoverColorGround;
private Renderer rend;
public Material startMaterialGrass;
public Material startMaterialGround;
void Start()
{
rend = GetComponent<Renderer>();
}
void Update()
{
void OnMouseEnter()
{
rend.materials[0] = hoverColorGrass;
rend.materials[1] = hoverColorGround;
}
void OnMouseExit()
{
rend.materials[0] = startMaterialGrass;
rend.materials[1] = startMaterialGround;
}
}
}