I made the following code to import a mesh. The compiler claims that no MeshImporter isn’t a member of UnityEngine.Mesh. What can I do to create the wanted feature?
var MeshObj : Mesh = Mesh.MeshImporter(“3001”);//name of the imported meshObject
var Vector : Vector3 = new Vector3( 3, 0, 2 );
You don’t actually need to write any code at all to import or draw a mesh. You merely need to put the mesh asset file (.fbx, .mb, .ma, .blend, etc) into your Project View. Unity will then automatically import the mesh and keep it available to you in the Project View. To draw the mesh, you simply instantiate the asset object by dragging the file from Project View into your Scene View or Hierarchy View.
I allready read all of the manuals. But they don’t seem to give me the answer.
If I drag the object into the Project View and then into my Scene View, then I guess the object will be viewable from the beginning of runtime? THis isn’t the desired solution. The object should ONLY be visible when I push a button during runtime.
Probably easier if you just have the object’s renderer set to disabled at the beginning. Then do object.renderer.enabled = true when you want it to show up. Instead of the mesh thing.
I didn’t expect a button to do the job just like that. I expect a script or some other code to do the job. I just didn’t have a clue on how to do the code or the script. But I’ll try to implement the solution that is show lastly.
As written in the last reply I thought about having all of the objects in the View at runtime, too. Just to make them invisible and then if the user chooses the object from a button then a clone of the object will become visible. That was one of my ideas to implement today. Is that what you sugested, Erik?