GL.Lines: Shader is not supported ?
Hi all,
Running Unity 5.2, I'm having this problem when rendering GL.Lines: all lines looks pink, and I got this error message: "Shader warning in 'Lines/Colored Blended': Shader is not supported. Are you creating a fixed function shader using Material(string) constructor?."
I used to create the shader on Awake, and I could draw lines colored. But on Unity 5.2 is not working anymore.
Any ideas? Thanks!
private void Awake()
{
if (!lineMaterial)
{
lineMaterial = new Material("Shader \"Lines/Colored Blended\" {" +
"SubShader { Pass { " +
" Blend SrcAlpha OneMinusSrcAlpha " +
" ZWrite Off Cull Off Fog { Mode Off } " +
" BindChannels {" +
" Bind \"vertex\", vertex Bind \"color\", color }" +
"} } }");
lineMaterial.hideFlags = HideFlags.HideAndDontSave;
lineMaterial.shader.hideFlags = HideFlags.HideAndDontSave;
}
}
private void OnRenderObject()
{
GL.PushMatrix();
lineMaterial.SetPass(0);
GL.Begin(GL.LINES);
GL.Color(lineColor);
GL.Vertex(A.transform.position);
GL.Vertex(B.transform.position);
GL.End();
GL.PopMatrix();
}
Answer by BabilinApps · Sep 18, 2015 at 08:23 PM
This is due to Unity trying to phase out shader code inside of your c# and js code. One way to fix it would be to use the defuse shader. Just make sure to add it in your project when you export. or you could add the shader in a Resources folder. I have added the shader that I use. Then you can call it with
lineMaterial = new Material(Shader.find("Custom/GizmoShader"));
or try
lineMaterial = new Material(shader.find( self-illumin/diffuse ));
Thanks BabilinApps, I found this shader did the job for me...
line$$anonymous$$aterial = new $$anonymous$$aterial(Shader.Find("Particles/Alpha Blended"));
Answer by Learn_Unity · Jan 05, 2016 at 01:52 AM
Best Answer. It solved after I add the shader in my Resources folder.
When shader is in the Resources folder - Unity gives me message: "An asset is marked with HideFlags.DontSave but is included in the build:" and breaks making a build. But it doesn't check this asset continiously, so it is just enough to rename it, after it detects and marks it again - rename again and so on and so on.