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 Zavalas · Jun 18, 2015 at 04:44 AM · buttonresolutionbutton trigger eventsaspect-ratiounityui

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

I've disabled the resolution dialogue, as I am letting the user change the resolution in game. I am then saving the users selected resolution with playerprefs.

My canvas scaler's reference resolution, as well as my playersettings default resolution, is set to 1920 x 1080, which is a 16:9 aspect ratio. As an example, when I try to set the resolution to 1680 x 1050, a 16:10 aspect ratio, it all loads fine and looks like it should, but all the UI buttons clickable area shifts to the left, off the actual object/sprite.

However, the area only shifts when it first loads the game. The buttons also work fine when fullscreen is not enabled. It starts working as it should if I manage to find the clickable area on the buttons to change the resolution, then change it back.
For example:

-The game loads the playerprefs and sets resolution to 1680 x 1050

-The clickable area has shifted

-Finding the buttons, I change it to 1920 x 1080

-The buttons work perfectly

  • then change it back to 1680 x 1050

-The buttons work perfectly

This might be related to how the canvas scaler component works, as I came across this in the documentation:

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.

But I guess I don't fully understand what this is telling me, assuming it's even relevant to my problem. From everything I've seen and read, my UI should be behaving normally. I've changed the settings of Screen Match Mode and other settings, but no results so far.

Here are my canvas scaler settings:

Ui Scale Mode: Scale with screen size

Reference Resolution: 1920 x 1080

Screen Match Mode: Match Width Or Height

Match: 0.5

Reference Pixels... : 100

Any help would be greatly appreciated

Comment
Add comment · Show 2
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 SarkanyIndustries · Aug 17, 2015 at 11:11 PM 0
Share

Hey there!

I've got the same problem on a 2D Project, which I already posted a question for...

But I haven't used playerprefs before and I don't really know how to change resolution in game!

I would suggest you change resolution in game twice by script, as soon as your game starts... According to your explanation the buttons should work correctly this way.

I guess I have to do it the same way, until a better solution for the problem is found.

avatar image asim314 · Mar 30, 2016 at 11:57 AM 0
Share

hey Guys! I also have the same problem any solution for it will be appriciated.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by acclogin71 · Jul 21, 2018 at 02:15 AM

have you found the solution yet?

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

UI resolution issues - Build EXE 5 Answers

Use Singleton Prefab in Button's onClick editor field 0 Answers

How do I create a Gmod item spawn menu in unity? 0 Answers

Make buttons visible in the editor? 2 Answers

how to create a button that call to action a website 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