Why does my custom model turn black after adding a texture

OK here is my problem. I’ve been trying to find a way to programatically add a texture to my a custom model (cat, dog, elephant etc) There are 350 models and i don’t want to manually add a texture to each one.
The code i use is

GameObject my3DModel = Instantiate(Resources.Load("Models/" + this.TrackableName, typeof(GameObject))) as GameObject;

and I load the texture with this

Texture my3dModelTexture = Instantiate(Resources.Load("Models/" + this.TrackableName, typeof(Texture))) as Texture;

The thing is when i add the texture regularly as in drag drop into model it works without any problems.

But when i use this code

my3DModel.renderer.material.mainTexture = my3dModelTexture;

my whole model turns black.
I just cannot figure out why this is.
Any help would be much appreciated.

Don’t use intantiate to load a texture, just Resources.Load. The path is probably incorrect as well, as it’s the same than the prebab. Note that model usually refers to the imported object that contains the mesh. A prefab is a GameObject with all it’s components saved on the disc.

renderer.material.mainTexture = renderer.material.GetTexture(“_MainTex”);

I dont know if that can work but try adding it after, if its not working
i would recommand you to change of Material instead of textures