Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by pojomcbooty · Jun 08, 2015 at 05:26 AM · uibuttonresolutionaspect-ratiowindows-7

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

5 Replies

· Add your reply
  • Sort: 
avatar image
4

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 :)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

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. alt text

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.


canvas-scaler.png (9.9 kB)
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image pojomcbooty · Jun 10, 2015 at 10:06 PM 0
Share

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

my basic test system

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.

ui-issues.png (239.0 kB)
avatar image
0

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:

  • http://docs.unity3d.com/Manual/script-CanvasScaler.html

  • http://docs.unity3d.com/Manual/HOWTO-UIMultiResolution.html

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image pojomcbooty · Jun 13, 2015 at 12:56 PM 0
Share

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 !

avatar image
0

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Button position scaling weird 1 Answer

Unity 5 new UI Button Colliders moved to the left in different resolutions 1 Answer

Inconsistent Sprite location on screen 1 Answer

Clickable Area on UI buttons get shifted when starting game in aspect ratio that differs from canvas reference resolution 2 Answers

how do i make ui that scales on any screen,How do i make UI that scales to any device 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges