Answers for "unity change color on mouse over"

C#
1

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;
	}
}
Posted by: Guest on May-06-2021

C# Answers by Framework

Browse Popular Code Answers by Language