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
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
This function will work well in unity editor as Editor can look for all available Shader in unity engine.
When build, unity will ignore Shader.Find("Unlit/Color") at build time and not include shader in build.
This make shader turn pink when run.
To enforce a shader include in build, there are two options:
Option 1:
Go to:** Edit → Project Settings → Graphics
Find "Always Included Shaders"
Click + and add "Unlit/Color" or your custom shader name
Option 2:
Create a material with your custom shader at Assets/Resources/Materials
Add below code on awake
When a material is load, this shader used by material will be auto included at build time
void Awake()
{
Material boardMaterialforLoad = Resources.Load<Material>("Materials/Board_Material");
....
}