- Home /
UI resolution issues - Build EXE
I finally came back to Unity after 4 years absence, I learned the new UI system in about an hour, seems awesome.
However, I've just built some UI buttons that work fine on all resolutions in the editor, but when I publish a windows EXE, one of the buttons you have to hover right into the middle of it (edges ignored), and the other you have to hover to the left of it.
now I've just figured out this works fine in a windowed mode, and in some of the resolutions, but for example I've a 1920x1080 monitor and if I launch in 1280 x 1024 the button dimensions don't seem to be right - I mean they look okay, but I can't click on them properly, it's as if the hitbox is in the wrong shape and/or size.
Now I assume this is something to do with aspect ratio, but it works in all aspect ratios etc in the editor - so do I just have to test each resolution and disallow any aspect ratios that break?
This seems counter-intuitive - there must be something simple I've missed...
Any ideas?
I really appreciate any assistance given! :-D
Windows 7 x64 build
Answer by digzou · Jun 08, 2015 at 07:11 AM
In the 'canvas scaler' component of your buttons' parent canvas, set the 'UI Scale Mode' to 'Scale with screen size'.
Then provide a reference resolution[Your default resolution on which you've built it], and set the 'Match' value to 1.
Your elements should scale proportionally now. Hope it helps :)
Answer by JairusLeonard · Jun 08, 2015 at 07:45 AM
Do you have a canvas scaler? If you don't have one you can try adding it and set it to something like this.
Also, make sure the placeholder for each canvas elements is just right for their intended size or else they will overlap and the object sorted in the back will not detect any click or touch input.
Thanks anyway - tried this but to no avail. my screen is indeed 1920 x 1080 - and if I launch the EXE in that resolution and full screen all is fine.
1280 x 1024 - all messed up
1280 x 1024 and windowed - works fine
all resolutions in the built EXE - when I click a button it changes from "Normal colour" to "highlighted colour" and then gets stuck there.
any aspect ratio is fine in the editor, it's only built EXEs that are messed up
I hate this - I can do almost any game mechanic but I've never been able to make even a basic Unity UI that works.... arghhh
I thought this would save me from onGui etc.
Answer by pojomcbooty · Jun 13, 2015 at 07:07 PM
Sorry - it was a total n00b /lazy question, now that I have a few minutes I can see it's all covered in the following docs properly:
in particular the Canvas Scaler doc says this:
If the current screen resolution has a different aspect ratio than the reference resolution, scaling each axis individually to fit the screen would result in non-uniform scaling, which is generally undesirable. Instead of this, the ReferenceResolution component will make the Canvas resolution deviate from the reference resolution in order to respect the aspect ratio of the screen. It is possible to control how this deviation should behave using the Screen Match Mode setting.
figured my other issue with the highlight colour that stays on the button after it is clicked. To fix this I set "Naviation" to "None". Cheers for your help all !
Answer by DigitalCandy · Jan 08, 2016 at 10:03 AM
In various unity versions, including 5.3.1, the canvas scaler doesn't scale properly in full-screen, non-native resolutions. It's a known bug seemingly related to multiple displays
Answer by SilverStorm · Jul 11, 2016 at 02:16 PM
One solution that worked for me was to disable the "Use Dx11" option in Player Settings, that sorted it all out for me.