void Createlinematerial ()
{
if (!mat)
{
Mat = 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}" +
"} } }");
Mat.hideflags = Hideflags.hideanddontsave;
Mat.shader.hideFlags = Hideflags.hideanddontsave;
}
}
void Onpostrender ()
{
if (!mat)
{
Createlinematerial ();
Return
}
Gl. Pushmatrix ();
Mat. SetPass (0);
Gl. Loadortho ();
Gl. Begin (GL. QUADS);
Gl. Color (color.red);
Gl. Vertex3 (0, 0.5F, 0);
Gl. Vertex3 (0.5F, 1, 0);
Gl. VERTEX3 (1, 0.5F, 0);
Gl. Vertex3 (0.5F, 0, 0);
Gl. Color (Color.cyan);
Gl. Vertex3 (0, 0, 0);
Gl. Vertex3 (0, 0.25F, 0);
Gl. Vertex3 (0.25F, 0.25F, 0);
Gl. Vertex3 (0.25F, 0, 0);
Gl. End ();
Gl. Popmatrix ();
}
Unity3d in a building GL material can change colors and show samples