代码语言:txt复制
usingUnityEngine;
usingSystem.Collections;
public class MouseEvent_Color : MonoBehaviour
{
//物体初始颜色
private Color CubeColor;
private Texture CubeTexture;
private GameObject ObjCube;
voidStart ()
{
ObjCube = GameObject.Find("Cube");
ObjCube.renderer.material.shader = Shader.Find("Diffuse");
CubeColor = ObjCube.renderer.material.GetColor("_Color");
CubeTexture = renderer.material.GetTexture("Cube");
}
/// <summary>
/// 鼠标经过
/// </summary>
void OnMouseOver()
{
renderer.material.color = Color.red;
}
/// <summary>
/// 鼠标进入
/// </summary>
voidOnMouseEnter()
{
renderer.material.color = Color.red;
}
//鼠标离开
voidOnMouseExit()
{
renderer.material.color = CubeColor;
}
}