码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2015-12-12 10:58:15      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:

    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在一建筑GL材料可以改变颜色和显示样本

标签:

原文地址:http://www.cnblogs.com/yxwkf/p/5040881.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!