GetMouseButtonDown not working for GL.LINES

Im trying to draw lines using mouse button.

Im able to track mouse movement using mousePosition(). But mouseclick event is not detected.

function OnPostRender()

{
    CreateLineMaterial();

    lineMaterial.SetPass( 0 );

    GL.PushMatrix();

    GL.LoadOrtho();

    GL.Begin( GL.LINES );

    GL.Color( Color(1,1,1,1) );

    GL.Vertex3( 0, 0, 0 );

    GL.Vertex3( Input.mousePosition.x/1919, Input.mousePosition.y/1019, 0 );

    GL.End();

     GL.PopMatrix();

    if (Input.GetMouseButtonDown(0)) 
    print(Input.mousePosition);
}

What am i doing wrong here?

Put Input.GetMouseButtonDown in Update.

–Eric

Yes Update reads mouse events, But it does not render GL.LINES.

Solved it using flags to check both Update and OnPostRender.

It’s not a matter of using OnPostRender or Update, it’s using both.

Edit: as you evidently discovered. :wink:

–Eric