回忆一下每一秒换一个颜色的方法
值得注意的是 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;
}

这篇博客介绍了在Unity中如何让物体表面颜色随机变化的两种方法:通过更新每一帧和使用Itween插件。代码示例展示了如何修改MeshRenderer的material颜色,以及对Itween插件中颜色变化相关函数的简单说明。
最低0.47元/天 解锁文章
660

被折叠的 条评论
为什么被折叠?



