unity change color on mouse over code example
Example: unity change color on mouse over
public class MouseOver : MonoBehaviour {
private Color basicColor = Color.green;
private Color hoverColor = Color.red;
private Renderer renderer;
void Start() {
renderer = GetComponent<Renderer>();
renderer.material.color = basicColor;
}
void OnMouseEnter() {
renderer.material.color = hoverColor;
}
void OnMouseExit() {
renderer.material.color = basicColor;
}
}