- Home /
Import a 3D model in Game (during runtime in GUI)
Hi guys , i am creating an editor or something like that .. where you can create your own model from cubes , spheres ... but what is important for me .. is it possible in unity to import a 3D model during gameplay through GUI ? i mean i will click on "import model button" and a file explorer will apear , i choose my model and it will place it to 0,0,0 for example ... ??
Thanks
It is possible. The object has to preferaby be a .obj file though.
Answer by Professor Snake · Feb 18, 2013 at 09:46 PM
Take a look at this wiki page: http://wiki.unity3d.com/index.php?title=ObjImporter
Attach this to something and then call ImportFile("path here") which will return an object of the type "Mesh". Then you can easily instantiate an empty gameObject with a MeshRenderer and assign the imported mesh to it:
GameObject emptyPrefabWithMeshRenderer;
String meshPath;
GameObject spawnedPrefab;
Mesh importedMesh=GetComponent("ObjImporter").ImportFile(meshPath);
spawnedPrefab=Instantiate(emptyPrefabWithMeshRenderer,transform.position,transform.rotation);
spawnedPrefab.GetComponent(MeshFilter).mesh = importedMesh;
Hey, so this just imports the $$anonymous$$esh
, do you know how to import materials as well?
Answer by gusholiday · Mar 26, 2016 at 06:52 PM
@markmesiter88
Might not be helpful but you could it in the http://wiki.unity3d.com/index.php?title=ObjImporter file.
Answer by markmeister88 · Aug 27, 2013 at 05:39 PM
Hi, i used the ObjImporter to download an obj from the web.
Is there any way to read also materials and apply to the GameObject?
Hi! Can you explain me how did you integrate the download from web please?
Your answer
Follow this Question
Related Questions
Importing GIS data 0 Answers
Skinning character (attaching mesh to skeleton) 2 Answers
Import Models 1 Answer
Importing colors with models 1 Answer