//材质要记得加工程中添加材质
public Material material;
//绘制方法系统回调
void OnPostRender()
{
if(!material)
{
Debug.Log("material == null");
return;
}
//设置该材质通道,0为默认
material.SetPass(0);
//设置绘制2D图像
GL.LoadOrtho();
//GL开始绘制,类型为线段
GL.Begin(GL.LINES);
DrawLine(0,0,200,100);
//结束
GL.End();
}
void DrawLine(float x1,float y1,float x2,float y2)
{
GL.Vertex(new Vector3(x1 / Screen.width , y1 / Screen.height, 0));
GL.Vertex(new Vector3(x2 / Screen.width , y2 / Screen.height, 0));
}