

I'm still experimenting with how to adjust for that. The x-coordinates increase to the right y-coordinates increase from top to bottom. Points on the screen are described by x- and y-coordinate pairs. The basic unit of measure is the device unit (typically, the pixel). Now when I click on my minimap, the location is off diagonally to a point (and relative amount) to a location to the upper-right of where the user clicked on the minimap. The coordinate system for a window is based on the coordinate system of the display device. Now, I click to maximize my screen, the resolution increases to around 1920 x 1080.
#Find mouse coordinates code#
The code works at this resolution (with a raw image width and height value of 170). I'm also not sure how the "Canvas Scaler" might play a role in it.įor example, currently in my Unity editor my screen resolution is somewhere around 800 x 600. I just can't think of the math formula to convert it based on screen resolution (or if there's a way to reference the image size).


So that "170" value number in my code needs to fluctuate depending on the pixel width and height of the raw image. I'm fairly certain it has to do with the screen resolution actually. To set the mouse position, you will have to use Cursor.Position and give it a new Point: Cursor.Position new Point(x, y) You can do this in your Main method before creating your form. I'm not about to write code here as it's offtopic to OP.Ĭlick to expand.Well the calculations run every time the user clicks on the minimap, so that shouldn't be a problem. Cursor.Position will get the current screen poisition of the mouse (if you are in a Control, the MousePosition property will also get the same value). If you need to transform world coord->rendertexture camera->rawimage->screen coords on UI, then reverse all 4 steps.
