How to obtain mouse position relative to Transform.position

I want to get the position of the mouse when the user clicks a button in the game. However the position I get using Input.mousePosition is in pixels and it starts at the bottom left corner. The staring point is “fixable” by substracting it from Screen.Width and Screen.Height, but I need the position I get not to be in pixels but to be in the same scale I use to move GameObjects (ie. gameObject.Transform.Position != Input.mousePosition fixed). How can I convert pixels to that scale?

I should note that my game is a 2D game, so the only relevant axis are X and Y.

Thanks in advance.

mousePosition isn’t just in pixels… it’s in another Vector space called Screen Space.

The position of a gameObject.transform is in World Space, so you are comparing apples and oranges. You can get the position of the mouse projected into World Space.