public class ActiveMeshRender : EditorWindow { private bool display; [MenuItem("Tools/ArtTools/显示隐藏碰撞 %#&V")] static void Init() { EditorWindow.GetWindow(typeof(ActiveMeshRender)); } private void OnGUI() { if (GUILayout.RepeatButton("显示碰撞")) { display = true; DisplayAndHiddenCollisionMeshRender(display); } if (GUILayout.Button("隐藏碰撞")) { display = false; DisplayAndHiddenCollisionMeshRender(display); } } void DisplayAndHiddenCollisionMeshRender(bool dis) { foreach (var mesh in Selection.transforms) { int index = mesh.childCount; for (int i = 0; i < index; i++) { mesh.GetComponentsInChildren<MeshRenderer>()[i].enabled = dis; } } } }
场景脚本显示隐藏碰撞
于 2022-01-29 13:01:12 首次发布