全局控制物体是否显示
public static void ShowObj(GameObject obj,bool show) { UnityEngine.Renderer[] allObj = obj.GetComponentsInChildren<UnityEngine.Renderer>(); foreach (Renderer a in allObj) { a.renderer.enabled = show; } //两种方法 for (int i = 0; i < allObj.Length; i++) { allObj[i].renderer.enabled = show; } }遍历指定的物体,设置显示或者不可见
原文:http://blog.csdn.net/myk7694503/article/details/43532747