As stated here I am not the only one finding the following problem:
Shader.Find returns a Null.
In the link above they gave a solution by creating something(?) in the Resource Folder, but I am not sure I understand. First, is this necessary for all cases? (meaning Shader.Find does not work by itself?) Second, what should I add? An unlit shader?? a material? Very confused here
I could solve the problem finally by doing the following:
First, go to unity editor: Edit->Project Settings-> Graphics Then in the inspector where it says "Always Included Shaders" add "Unlit/Texture"
Then change my Shader.Find code to read Shader.Find("Unlit/Texture");
With this it does not return null anymore
You should add your shaders to any of the scene objects otherwise they work only in editor. Add your shader to Resource Folder or you can create new one.
In Resource Folder
RightClick -> Create -> Material When you select the material you will see the shader field in inspector,choose the suitable one for you.
For example: in my script;
var newMtl = new Material(Shader.Find("Standard (Specular setup)")) { name = materialName };
So I added the material and select Standard (Specular setup) as the shader.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With