您的位置:首页 > 移动开发 > Unity3D

Unity3D在一建筑GL材料可以改变颜色和显示样本

2015-12-12 10:35 435 查看
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();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: