.................................
Color tempcolor;
Material tempmat;// Use this for initialization
void Start () {
tempmat = GetComponent<Renderer> ().material;
tempcolor = GetComponent<Renderer> ().material.color;
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown (0)) {
Color mcolor = new Color (tempcolor.r, tempcolor.g, tempcolor.b, 0.2f);
tempcolor = mcolor;
Debug.Log (tempcolor);
tempmat.color = mcolor; //会改变gameobject的材质颜色
tempcolor=mcolor; //不会改变gameobject材质颜色
}}
tempcolor是material.color的reference,不能改变material