Unity3D:如何更改 Transform(GameObject)的颜色?
Unity3D: How to change Transform's (GameObject's) color?
老版本Unity Component的渲染器有material,现在UnityEngine.Renderer有material,但是Component.renderer没有。
如何更改对象的颜色?
private Transform myTransform;
...
private void changeColor()
{
myTransform.renderer.**material**.color = Color.red;
// renderer doesn't have *material*
}
通过这个thread,试试
GetComponent<Renderer>().material.color = Color.black;
老版本Unity Component的渲染器有material,现在UnityEngine.Renderer有material,但是Component.renderer没有。 如何更改对象的颜色?
private Transform myTransform;
...
private void changeColor()
{
myTransform.renderer.**material**.color = Color.red;
// renderer doesn't have *material*
}
通过这个thread,试试
GetComponent<Renderer>().material.color = Color.black;