So I am making basic tiles on a plane and am trying to get the following script to apply to the prefab of the tiles:
using UnityEngine;
public class MouseOverTile : MonoBehaviour
{
public Color highlightColor;
Color normalColor;
void Start()
{
normalColor = GetComponent().material.color;
}
// Update is called once per frame
void Update()
{
Ray ray = GetComponent().ScreenPointToRay(Input.mousePosition);
if (GetComponent().Raycast(ray))
{
GetComponent().material.color = highlightColor;
}
else
{
GetComponent().material.color = normalColor;
}
}
}
However it wont work, what is wrong?