- Home /
Legacy GUI scaling on non native resolutions
Hello,
I have an older project that still uses some legacy GUI code. Starting the build in windowed mode and fullscreen mode in native resolution work without problems. However, if I run it in fullscreen, but at a non native resolution, the GUI doesn't really work as it should.
For example, a button is scripted like this:
if (GUI.Button(new Rect(Screen.width - 125, Screen.height - 55, 120, 50), "Start"))
{
// some code
}
The GUI gets scaled as expected, but the mouse input doesn't. Let's say I use a 1280x1024 resolution on a 1920x1080 screen. The button is displayed at the edge of the screen, as I intended it to, but doesn't react to the mouse hovering over it. I need to hover the mouse somewhere a little to the right of the center (i.e. where the 1200th pixel would be on a native resolution) for it to activate.
In other words, the display renderer functions as if the resolution was 1280x1024, while mouse input functions as if the resolution was 1920x1080.
How do I get the mouse input to transform its coordinates to the display resolution?
Your answer
![](https://koobas.hobune.stream/wayback/20220611230330im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
gui.button down 2 Answers
The Button in the middle activates if i press two side of the button. 0 Answers
Infinite GUI Button positions. 3 Answers
Making a Hover function for a button or toolbar from code. 2 Answers
Camera being disabled by any GUI button 2 Answers