changing resolution makes buttons not work properly

the ui is fine in the editor, and i have a canvas scaler set to scale with screen size in my canvas
but… trying different resolution makes ui elements go in the right place but their “hitbox” not work anymore, its like the hitbox for the button is fixed in the “subscreen”, anyway not there the button is actually placed, to click the button i have to click where the button would be in the default resultion

anyone knows why?

I don’t know why this happens, but I know how to fix it. You just have to make it windowed first, then change the resolution, like this:

        Screen.fullScreen = false;
        Screen.SetResolution (1920, 1080, true);

The issue for this is, as far as I can tell, if you go full screen and display a resolution with an aspect ratio that’s different from your screen’s actual native aspect ratio. At least that seems to do it for me.

This has been an annoying “bug” for awhile now. And by bug, I mean just bad programming really. From the googling I’ve done, it looks like Unity is aware of this issue actually, but it won’t be fixed until 5.2 or a dot release thereafter. Which is somewhat surprising considering how major of a bug this is.

As Martin said, it has to do with going “fullscreen” mode in dx11 on non-native aspect ratios. If you play around a bit, you’ll notice that the “hitbox” of the button (as you put it) works if you minimize your game into windowed mode from fullscreen mode .

Essentially, the button hitbox follows the “windowed mode” setting, but NOT the fullscreen setting. I can actually click on “ghost” buttons in fullscreen mode if I guess where the button would be in windowed mode – which I’ve done more than I should. It could actually be a game itself really: Guess where the button hitbox actually is on the screen in Unity…Simulator 2015 :slight_smile:

2 Likes

Lol, how much is it selling for?
:smile:

Hi I seem to be having the same issue using Unity 2019.4.1f1

When I scale my game to a different resolution, the UI buttons scale accordingly and they are placed properly. However in order to interact with them I have to click far away from the button (their hitbox has been moved).

It only happens in fullscreen mode, when I make the game windowed then the error goes away

is this a bug that still has not been solved in Unity?

Well, I guess not. Working on 2019.4.17f1 and still getting the same issue…

Well well well … Unity 2021.3.3f1 and still having this issue :slight_smile:
It was not here before though, 2021.3.2f1 was fine
But the new version resurrected it

however this only happens in windowed and not in fullscreen

1 Like

it’s bug from ugui
Since author has not fixed this problem, I offer a solution:

this issue from class MultipleDisplayUtilities.RelativeMouseAtScaled
It is a different call in the editor than it is at build run time
at a particular resolution, the mouse position is incorrectly calculated

you can annotation defined include code to ensure same editor if you can custom package ugui ()

Note: i think this code is to fix the issue, but it’s make a bigger issue
5.3 Multi-Display Feature Issues... page-4

I am still having this issue in Unity 2023.3.0a10. How can I build apps if such bugs persist? I just changed my ios screen to max pro 12 and the buttons are not working on the phone nor in editor… what to do? Does anyone have a solution?