- Home /
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.
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?
Did you ever find the solution for this? I'm looking for the same thing, though can't find the solution anywhere.
Answer by Nghia · May 09, 2017 at 05:49 AM
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;
Your answer
Follow this Question
Related Questions
Load a mesh from Resources in the Scene 0 Answers
Resources.Load("sprite") returning nil 0 Answers
Prevent LoadLevelAdditiveAsync from halting the app? 3 Answers
Static objects increasing load time in Unity 5? 2 Answers
moving hole 3 Answers