改变对象颜色
using UnityEngine;
public class ChangeColor : MonoBehaviour
{
void Update()
{
if(Input.GetKeyDown(KeyCode.R))
{
GetComponent<Renderer>().material.color = Color.red;
}
if(Input.GetKeyDown(KeyCode.G))
{
GetComponent<Renderer>().material.color = Color.green;
}
if(Input.GetKeyDown(KeyCode.B))
{
GetComponent<Renderer>().material.color = Color.blue;
}
}
}