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
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
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?
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 ()
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?