unity给物体更改颜色
新建一个你要绑定的物体,如cube,在cube下新建script脚本:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class color : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
GetComponent<Renderer>().material.color = new Color(1, 0, 0);//(R,G,B)案例红色
}
}
这样即可完成简单的颜色更换。