- Home /
Find right mesh for collider
For my script I need to use a mesh collider. All of my prefabs have a child with Default (Mesh Filter) && Mesh Renderer. Is there a way to find the right mesh through a script or something else? I can just find them and drag them but I'm talking about 1500+ prefabs.
               Comment
              
 
               
              Default ($$anonymous$$esh Filter) has the right mesh, but is there a way to assign that mesh, in the mesh collider in the parent?
 
               Best Answer 
              
 
              Answer by Chizukoo · Oct 17, 2019 at 11:32 AM
For anyone else with this question:
 MeshFilter meshFilter = GetComponentInChildren<MeshFilter>();
 MeshCollider meshCollider = GetComponent<MeshCollider>();
 meshCollider.sharedMesh = meshFilter.mesh;
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                