- Home /
Load Object(3d model) by name with script at scene
Hello everone! i want load a object (3D model) into a scene by name with script, i have 5 object and i want load at a scene unique... thanks
Answer by whebert · Mar 20, 2013 at 08:44 PM
If you place your models into the "Resources" folder within the "Assets" folder, you can use the following to load it at run time.
var loadedObject : GameObject = Instantiate(Resources.Load("modelName"));
Note that "modelName" is the string path of your model inside the Resources folder and does not contain the model extension. Say if your model was an OBJ file named model.obj, you would only put in Resources.Load("model");
Answer by whydoidoit · Mar 20, 2013 at 08:41 PM
Put them in a Resources folder and load them with Resources.Load(objectName, typeof(Mesh)) as Mesh
Follow @whebert 's example if you actually mean a prefab game object not a mesh.