标签:效果 use update span rail pre 材质 void tar
public class metrailstest : MonoBehaviour { Material[] m; Material i; public Material[] n; int index = 0; // Use this for initialization void Start() { i = this.GetComponent<MeshRenderer>().material; m = this.GetComponent<MeshRenderer>().materials; } // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.A)) { index++; if (index % 2 == 0) this.GetComponent<MeshRenderer>().materials = n; else this.GetComponent<MeshRenderer>().materials = m; } } }
效果如下:
代码动态更换MeshRenderer的材质Materials
标签:效果 use update span rail pre 材质 void tar
原文地址:http://www.cnblogs.com/unityzc/p/7687889.html