Skip to content

Instantly share code, notes, and snippets.

@danielbierwirth-unity
Created May 5, 2022 07:18
Show Gist options
  • Select an option

  • Save danielbierwirth-unity/4c3e82e66a70d5de7f4fc01623669dce to your computer and use it in GitHub Desktop.

Select an option

Save danielbierwirth-unity/4c3e82e66a70d5de7f4fc01623669dce to your computer and use it in GitHub Desktop.
Create small menu entry to disable all mesh renderers attached to a GO - use this for collision meshes
[MenuItem("MyTools/DisableMeshRenderer")]
static void ApplyToSelected()
{
Debug.Log("Apply to selected");
GameObject[] selectedObjects = Selection.gameObjects;
foreach (GameObject obj in selectedObjects)
{
if (obj.GetComponent<MeshRenderer>() != null) {
obj.GetComponent<MeshRenderer>().enabled = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment