- Home /
Script: import a 3d model to the scene from an outside folder
Hello everyone,
I'm still a beginner to unity3d and I have a question about how to import a 3d model from outside the assets folder.
For the need of my client, I have to read a xml file (stored outside the assets folder at a fixed path) in order to retrieve several information for each 3d model (position, rotation, scale and so on).
My client wants to store all fbx models outside the assets folder in order to change 3d models anytime he wants after exporting the project (plateform will be Windows).
As a result my project (scene, script, everything in the assets folder) will be pretty empty except some script in order to manage the xml file.
I've already succeeded to load a texture stored outside the assets foilder and set it to a model which was added to the scene manually.
My question is: knowing the fbx file path (eg: c:/models/target.fbx), can I import the fbx model and put it to my scene by script?
Every data will be stored oustide the assets folder, and so far when searching to the internet I find nothing for importing a 3d model to the scene by script. So far I only know how to add a prefabs into my scene when having a GameObject set (Instanciate(myGameObject);)
Could you please tell me if my client request is possible? (I'm willing to use C# script)
I really thank you in advance
hello. $$anonymous$$e too i need import a 3d model (.fbx or obj) to the scene from an outside folder. So do you have any workaround ?
Answer by Louis Watson · Sep 24, 2014 at 03:21 AM
Look Here: Importing Mesh from script
Note a model is a collection of objects rather than being one item. you could render a whole scene in one .fbx if you wished. you could hook up each item to their corresponding renderers i.e. for meshes and materials.
Thank you very much for your reply.
I've looked at your url and I don't really understand how to proceed with the $$anonymous$$esh. Does the $$anonymous$$esh type contain my whole fbx model with its animation and so on? In your link, they don't put a fbx(or whatever model file type) file path to the Resources.Load() function.
Furthermore, look like the Resources type can only parse file in the Assets folder and I want to load a fbx from a folder outside the Assets folder.
I've made more research on the unity forum and find another post which is the same thing I want to achieve : http://forum.unity3d.com/threads/loading-fbx-model-from-a-webserver.128344/
As I don't understand a thing about model file format, I can't create a model parser (and find nothing on the autodesk website neither).
thank you but the Strea$$anonymous$$gAssets is pointing the to Assets folder of my project and my fbx have to be everywhere but to the Assets folder. The fbx path will be set into a xml file which is also stored outside the Assets folder (xml file path is hard coded in the project).
i meet the same question, so do you have any workaround ?
the only workaround I found is to use assetbundle file (*.unity3d) ins$$anonymous$$d of fbx file. From Unity5, even with a free license we now can create assetbundle so the workaround consist to first convert the fbx into an asset bundle (create an empty sceen with only your fbx model in it) then export it as assetbundle. Once you have your assetbundle file, you can load your file from any path.
Your answer
Follow this Question
Related Questions
Switching scenes saves assets? 1 Answer
How can i make my imported 3d model collidable? 1 Answer
Is there a way to script the scene to pause itself or debug. 1 Answer
How do you import a character from Asset Store into your scene? 0 Answers
Cannot assign assets to variables via inspector: NullReferenceException 3 Answers