Input system get Vector2 mouse position by click

Can someone tell me how to get mouse position by click with new unity input system. I`m able to get mouse position but it updates every time position changes and i need to get value only by click.

This code prints the mose position on click.

void Update()
{
    Vector3 mousePos;

    mousePos.x = Input.mousePosition.x;
    mousePos.y = Input.mousePosition.y;

    if (Input.GetMouseButtonDown(0))
    {
        print(Mathf.Atan2(mousePos.x, mousePos.y) * transform.position);
    }
}

}

First, in your .inputactions asset, create a new action and bind it to the mouse click:
173922-clickaction.png

Next, if you don’t already have one, add a PlayerInput component to a GameObject in your scene. Set the PlayerInput component to use your inputaction asset. Set Behavior to “Use Unity Events”. Then click the little triangle to open the dropdown list of events, and add a custom function to the Click event:

Lastly, put some logic in your click handling function. You know how to get the mouse position, so in your click handling function, write the code to get the mouse position, and then whatever other code you need.

Consider reviewing the documentation on actions and action maps. This is, IMHO, the most useful feature of the new input system. Documentation is here: 3