Issues converting screen position to a position that can be used by RectTransform

I’m building a synchronization for a projected screen, and I’m having issues getting the position of the click to the correct position on screen. The position always converts with the idea that the center of the image I’m projecting is (0,0) rather than the bottom right hand corner of the screen. Any help on how to keep my (0,0) point at the bottom right?

Edit: I think the issue lies in the ScreenPointToLocalPointInRectangle with the image’s RectTransform being used for the screen calculation. I’ll switch it to the canvas to see if it helps

Edit2: The canvas change made it now have a consistent (0,0) point in the middle of the canvas, now just to figure out if it can be changed to the bottom right.

Edit3: Switching my position setting method from anchoredPosition to localPosition fixed the issue! It didn’t change the (0,0) position, but localPosition works with the (0,0) point in the middle of the canvas.

I forget the details of doing this but it was very fiddly. The key takeaway I remember is that you need to get the RectTransform from the parent canvas (generally up at the root from where you are) and use its values to scale your object’s values to meaningful ranges.

It is very fiddly, but luckily I figured out how to not worry about changing the (0,0) point. I just used the localPosition method instead of anchoredPosition.

1 Like