I am writing here as I have encountered a problem with Unity. I have written my own surface shader and want to use it for a prefab. However, when I drag and drop the shader to the prefab in the editor, it recognizes it but it doesn't change the prefab. The prefab is a prefab for some objects which stays pink. What's the problem? The shader works, and I know that as I have tried to drag and drop the shader directly to some of the objects. In addition to that, I have also tried to create a material an drag and drop the shader that and then drag and drop the material to the prefab. That didn't work either.
Make sure the game isn't running and drag your prefab into a scene and select it in the Hierarchy. There should be details in the Inspector that will allow you to apply your shader.
First, find the part of the prefab that contains a renderer (probably a
MeshRenderer). Under that component, there will be a "Materials" list which should have a size you can adjust and then elements to select the materials you'd like.
When your materials are set, there will be drop-down menus to select which shaders those materials are using; this is where you select the shader you want.
Finally, as with any adjustments to prefabs, you must click the "Apply" button in the upper right on the Inspector. If you make changes while the game is running or without clicking "Apply", the changes will not be saved to the prefab.