…but only if the web page initially loads on a Retina display. If I load it on my second (non-Retina) monitor, and then move it over to the Retina display, then it seems correct.
Here’s what I get when I load (or reload) the web page on a Retina display:
Note the debug info at the bottom of the screen. That (1992.0, 697.0) is the direct Input.mousePosition value when the mouse is near the upper-right corner of the game. To the right are the values of Screen.dpi (always 0) as well as Screen.width/height, Camera.pixelWidth/pixelHeight, Camera.scaledPixelWidth/scaledPixelHeight, and what I get from doing Camera.viewportToScreen(Vector3.one). All these report a display size of 1024x768. Yet Input.mousePosition (which is supposed to be in pixelWidth/pixelHeight coordinates) is giving me values twice as big.
When I drag the window over to my second (non-Retina) monitor and repeat the test, I get this:
Now the screen and camera are still reporting the display size as 1024 by 768 (which is what I requested in the build settings, BTW). But Input.mousePosition actually agrees: a point near the upper-right corner is reported as 997, 731.
Now I drag the browser window back to my Retina display, and get:
This time, for the first time, the screen size and camera sizes all say the display is 2048 x 1536 (exactly twice what I requested in the build settings). And this matches what Input.mousePosition reports, so I am able to correctly convert to my own coordinate system.
It’s puzzling that Camera.pixelWidth and Camera.scaledPixelWidth are the same under all circumstances; I thought the point of these was to report different values, in cases where we are on a scaled (double-resolution) display. But whatever. The real problem for me is that on initial load on a retina display, all ways of reporting the screen size flat-out lie, at least compared to what Input.mousePosition reports. And I can find no way of knowing when this is the case, short of asking the user to manually calibrate the mouse (which sucks).
EDIT: another weird observation: when things are working (i.e. on a non-Retina display, or moved to a Retina display from a non-Retina display), Input.mousePosition reports 0,0 at the bottom-left corner of the display. But when loaded on a Retina display, Input.mousePosition reports 0,0 at the middle-left side of the display. That’s why my computed Y values happen to look correct in all three cases above, when testing with a mouse pointer near the top of the screen. (That’s just coincidence; the computed values are wrong everywhere else.)
Has anyone else run into this? Any suggestions for a work-around?


