Get XY Pos of Mouse?

So, I tried getting the XY pos of the mouse on screen like this:

RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
       
        if(hit.collider != null)
        {
            Debug.Log ("Target Position: " + hit.collider.gameObject.transform.position);
            PosXY=new float[]{hit.collider.gameObject.transform.position.x,hit.collider.gameObject.transform.position.y};;
        }

However, bith X and Y are 0, and it doesn’t log anything. Anybody know why?

You are casting the ray along direction (0,0) which doesnt make sense

So Vector2.one?

I don’t know!
Which direction do you want to cast a ray?

There is a discussion about this here Unity 2D Raycast from mouse to screen - Unity Engine - Unity Discussions