I’ve an object with mesh renderer attached and I’ve a custom material which I want to set to the material of this mesh using C# script
My script code is -
after that I am stuck how to set the material to this mesh. I tried using mesh.renderer and mesh.material but there are no methods (at least I’m not able to figure out)
I want to set the material so I was searching for something like “Element 0” type property to which I can apply my material (which we can without using scripts by simple drag & drop the material to the Element 0 option) but there is no such property or method available. Please help me
ok just one more doubt . How should I initialize the materials[0] ? I’ve some Materials present in my Materials folder in the project pane but none of them is coming when I do this -
You have gotten two links to the manual already. It contains a lot of useful information and gives you an overview of what is possible. We are talking about a material, which is documented here:
You want to replace some images in it. If you just have a glance at the page, you should see mainTexture:
So, all the information you needed was already there. Use it!