unity, change shader for me and all my children

public void changeShaderForMeAndAllMyChildren(){

  Transform[] childrenTransformList = GetComponentsInChildren<Transform>();//注意GetComponentsInChildren包括自身

  foreach (Transform transform in childrenTransformList) {

    transform.GameObject.GetComponent<MeshRenderer> ().material.shader = Shader.Find ("Custom/myShader”);

  }

}

 

posted on 2015-06-26 14:14  wantnon  阅读(280)  评论(0编辑  收藏  举报

导航