If I only use 2 vertices for GL.LINES, I get a solid line as expected. However for some reason if I use more than 2 vertices, the line ends up looking dashed. I'm no GL expert, but a Google found glLineStipple is a command to draw lines like this. Why would Unity be doing it automatically, and only when multiple vertices are specified? Am I missing something? Here is my glLine() function in its entirety:
private static Material glLineMaterial = null;
public static void glLine(Vector3[] vectors, Color color)
{
if (glLineMaterial == null)
{
glLineMaterial = 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 }" +
"} } }" );
glLineMaterial.hideFlags = HideFlags.HideAndDontSave;
glLineMaterial.shader.hideFlags = HideFlags.HideAndDontSave;
}
GL.PushMatrix();
glLineMaterial.SetPass(0);
GL.LoadOrtho();
GL.Color(color);
GL.Begin(GL.LINES);
foreach (Vector3 vector in vectors)
{
// The Vector3 values come in as screen coords, but need to be converted to 0.0-1.0 for OpenGL.
Vector3 vectorGL = new Vector3(vector.x / Screen.width, vector.y / Screen.height, 0);
GL.Vertex(vectorGL);
}
GL.End();
GL.PopMatrix();
}
↧