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();
    }

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 ));

[54575-gizmoshader.zip|54575]

Best Answer.
It solved after I add the shader in my Resources folder.