This will be hard to explain, but I'll try to keep it short and simple:
I'm trying to set the position of a UI rectangle to the position of the mouse when clicked. When initialized, the position of the rectangle works fine (if, during Awake(), I initially set it so that x = 100 and y = 100 and then check the Rect Transform component during run time, Pos X and Pos Y are both set to 100 as intended). However, if I use the X and Y coordinates of Input.mousePosition, Pos X and Pos Y are given strange numbers that I have no clue where they're coming from.
I don't think they're pixel coordinates because the value for Pos X of the rectangle when my mouse clicks at the farthest left possible during run time is a value over 300 when it should be 0, and that value goes up as I progressively click rightwards.
Now here's the strange bit. When I try to use print() to print the mouse position x and y values that I use to set the rectangle's position, they're printed as intended (clicking the bottom left of the game area yields x = 0 and y = 0) yet the rectangle's position is far from close the values printed (rectangle's position is x = 337.5 and y = 192.5).
Can someone please explain why this happens, and how I can fix it? I suppose I can manually fix it by subtracting the new position values by 337.5 for x and 162.5, but it feels too brute-force-ish and there's bound to be consequences down the line.
Here is a screenshot to help clarify my issue: https://i.stack.imgur.com/6xebh.png
position
instead oflocalPosition
\$\endgroup\$