Custom shader turns pink when built

Anybody know why this would happen? I have a simple Diffuse Outline shader that I found on the unity forums, and I’m swapping out the shader when I have a target selected, so the selected target has an outline. It works fine in the editor- but as soon as it’s built, the shader stops working- instead of an outline around the target, the target turns pink- as if it’s missing its diffuse texture.

Any idea what would cause this? I thought when you built binaries, it pulled in any needed resources… if that’s the case, it should be a 1:1 representation of what I get in the editor, but that’s not the case. Any help on this would be appreciated!

Okay, so I finally got around to looking into this problem again- and it turned out to be something really simple. I was changing the shader via script, and the shader wasn’t in my Resources folder like I thought it was. Moving the shader to resources fixed it, obviously :slight_smile:

Another (better imo) way to do it, posted on the forums by Kaspar Daugaard, go to the Unity menu “Edit”, then select “Project Settings”, then go to “Graphics”.

Expand “Always Included Shaders”, then increase the “size” by 1, then click on the new element selection circle on its right and then select the shader you want to have loaded with your game.

In theory it should work as you described. You get pink shader when it’s unabled to find shader or compile it. Check log after running your build and see if there are any indications what went wrong with your shader.

First make a backup of your project then Delete all folder other than Assets in your project folder then run your project it will take time , then you must have to change platform then make a build and run. It will work 100% sure IA … Sorry for my bad English :slight_smile: