public static void Color (Color c);

描述

设置当前顶点颜色。

在 OpenGL 中,这与 glColor4f(c.r,c.g,c.b,c.a) 相匹配;在其他图形 API 中,对应的 功能是模拟实现的。

为使每顶点颜色在不同硬件间可靠工作,您必须使用在 颜色通道中绑定的着色器。请参阅 BindChannels 文档。

此函数只能在 GL.BeginGL.End 函数之间加以调用。

using UnityEngine;

public class Example : MonoBehaviour { // Draws a red line from the bottom right // to the top left of the Screen // And a yellow line from the bottom left // to the top right of the Screen Material mat;

void OnPostRender() { if (!mat) { Debug.LogError("Please Assign a material on the inspector"); return; } GL.PushMatrix(); mat.SetPass(0); GL.LoadOrtho();

GL.Begin(GL.LINES); GL.Color(Color.red); GL.Vertex3(1, 0, 0); GL.Vertex3(0, 1, 0); GL.Color(Color.yellow); GL.Vertex3(0, 0, 0); GL.Vertex3(1, 1, 0); GL.End();

GL.PopMatrix(); } }