I want to switch the renderer material during runtime.
I’ve tried googling, reading class docs… I’m sure that this has been asked and answered, but I can’t find it…
The most that I can get to happen is creating a material with the name of “Specular”, with a shader with the name of “Specular”, instead of the material “DoorSwing_unsecure” from the Assets/Materials folder, which does exist.
This is so frustrating right now!
void Update()
{
if(onetime == 0)
{
onetime = 1;
string textName = "DoorSwing_unsecure";
Material newMat = new Material(Shader.Find("Specular"));
Texture newTex = Resources.Load(textName) as Texture2D;
newMat.mainTexture = newTex;
renderer.material = newMat;
}
}
Please help me, I’m sure that this just so simple that it’s “stupid simple”, but I just can’t figure it out.
Thanks
[35756-screen+shot+2014-11-24+at+5.31.11+pm.png|35756]