回忆一下每一秒换一个颜色的方法
值得注意的是 Color中的范围是从0到1的
方法一:
using UnityEngine;
using System.Collections;
public class RandomColor : MonoBehaviour {
float time;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
time -= Time.deltaTime;
if (time<=0)
{
this.gameObject.GetComponent<MeshRenderer>().material.color = RandomColors();
time = 1;
}
//time += Time.deltaTime;
//if (time>=1f)
//{
// this.gameObject.GetComponent<MeshRenderer>().material.color = RandomColors();
// time = 0;
//}