title: Adding a MeshFilter mesh via script?
body: <p>How do you add a MeshFilter component with a specific mesh, let's say a Capsule mesh (from Unity default library resources), via C#? I'm this far ...</p>
  
  <pre><code>GameObject obj = new GameObject("Player");
  MeshFilter meshFilter = obj.AddComponent&lt;MeshFilter&gt;();
  meshFilter.mesh = 
  </code></pre>
  
  <p>Capsule and other primitive meshes are in the Unity default resources and I know how to assign it in the editor but how do I obtain one in C#? Obviously instantiaion isn't available since it's a library asset.</p>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>I would have thought that this would work:</p>
  
  <pre><code>meshFilter.mesh = Resources.Load&lt;Mesh&gt;("Capsule");
  </code></pre>
  
  <p>But the mesh is still null afterwards in the editor component inspector.</p>