Loading a mesh?

I am trying to access the objects listed below in the script. Specifically, I’m trying to access the Mesh objects like Prime0, Prime1, etc. (listed under the prefab objects) through a script.

alt text

However, I cannot seem to do this. This code fails, for example, (resource is null).

GameObject resource = (GameObject)(Resources.Load("AtomPrimes/Prime0", typeof(GameObject)));

I’ve tried other attempts, such as exporting each prime (Prime0, Prime1…) as individual meshes. However, this only works occasionally, while most of the time the mesh cannot be drawn after it is loaded.

The objects are in the resources folder.

How do I load a mesh?

Try this if AtomPrimes has only one mesh child

GameObject fbx = Resources.Load("AtomPrimes") as GameObject;
Mesh mesh = fbx.GetComponent <MeshFilter>().sharedMesh;

If AtomPrimes has many children

GameObject fbx = Resources.Load("AtomPrimes") as GameObject;
Mesh mesh = fbx.transform.Find ("Prime0").GetComponent <MeshFilter>().sharedMesh;