In my script I am switching between shaders like it shows how to in the scripting reference, with Shader.Find
This is pretty much how I use it my code, except I'm using a switch. Its for a ball select screen, many of the balls are the same sphere that just changes textures, and if I can get it to work, shaders.
This is basically how I have it work in my code
var shader1 : Shader = Shader.Find("Diffuse");
var shader2 : Shader = Shader.Find("Specular");
function Update()
{
//ballChoose is just an int that increases / decreases when next or previous buttons are pressed
switch(ballChoose)
{
case 1:
standardBall.renderer.material.shader = shader1;
break;
case 2:
standardBall.renderer.material.shader = shader2;
break;
}
}
This works fine in the editor, even though I get this error,
ArgumentException: Find can only be called from the main thread.
When I make a build, nothing happens, I just get a black screen, I think this error must be why because its the only error in my code.
After looking around I found out that you're only supposed to use Find inside of Awake or Start, but if I declare the variables in there then I cant use them in Update. So I was wondering if anyone knew of a way to change shaders without Find, or of any other way to make this work.
Thanks!