proper way to load resources folder model from script

What’s the proper way to load a model from a script?

Do I take a model and put it and it’s textures in the resources folder and then what code would I use to get it to

  1. Load
  2. Find it’s textures or materials
  3. render on screen

I can’t find an example of this.

Thanks,

Dan

Could someone field this question or point me to a scripting example?

Thanks,

Dan

With Resources.Load you get a handle to a specific resource, which you then must Instantiate to actually load it for usage.
Once you are done with the object, you need to manually free it through Destroy / DestroyImmediate again unless you use LoadLevel to completely clean the current scene

I still don’t understand how when you instantiate an object that it knows where to find the textures etc.

For example where do you put the textures for the object let’s say it’s fbx or some other format.
How does Unity know where to find them.

Also… I just put Lerpz in the resources folder and
loaded him as a resource and instantiated it.
But…there is no renderer attached to him yet I can still see him onscreen with the correct texture so this makes no sense.

why is lerpz rendering if there is no renderer?

If you don’t want to put the model together with texture assignements etc yourself through code, you would create prefabs. Thats what I would commonly recommend as you can configure components on the object etc too.

A prefab is simply put a blueprint of a game object with additional components including textures, meshes, functionality.

The documentation contains a fair amount of informations on prefabs

Lerpz: there is one attached. But its a prefab so you need to place him in the scene actually to see the hierarchy.