magenta color when try to SetColor on object

unity 5.2

i use this code inside the Start method to access 2 colors properties in the shader:

Renderer rend = GetComponent<Renderer>();
rend.material.shader = Shader.Find("SomeShader");

when i hit the play button, the object gets magenta color and there is a saying inside the shader selector (under material) says: “Hidden/InternalErrorShader”.

google search lead me nowhere
please help me

i found a way to SetColor different here:

that worked for me.

but i dont understand why the way i tried dont work… i used Unity documentation

I encountered this problem as well and none of the many “Pink Texture” answers solved it for me. Because I too call FF00FF “magenta”, I will post my answer here. :slight_smile:


My problem was with the line:

rend.shader = Shader.Find

I was passing in an incorrect name for the shader. If you do this in the editor, it will set the shader to “Hidden/InternalErrorShader (UnityEngine.Shader)” and then proceed as if all is well. Once you build it, will not.


For me, since I was using the Standard shader included with Unity, I just needed to pass “Standard” to the Find call, and then use “_Color” for the SetColor call. I then realized that my shader was already set to “Standard” because that was what I had set it to on my prefab, so I didn’t need the Find call at all.


My suggestion is to put a breakpoint at the line of code where to modify your materials and make sure that your shader is not set to InternalErrorShader. If you don’t need to change which shader is being used at runtime, then leave out the Find altogether.