Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by Moubien · May 09, 2017 at 06:57 PM · screen resolutionscaledown

instantiated button scaling issue

I have a button that is being instantiated within a scroll view . it has Layout Element attached to this Prefab button so I have to specify a width and height for it but the button is only being set correctly on 1 resoultion because if the resolution goes up or down the button are getting shifted up and down right and left . in short it's a mess the button doesn't scale with the screen resolution. Kindly if someone could help me I appreciate it becauase i can't find a way to fix this.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Ruri-Dev · May 09, 2017 at 08:22 PM

When using Instantiate for UIElements be sure to use the method-version: Instantiate(Object original, Transform parent, bool worldPositionStays) and setting the last bool to false to avoid issues. About the resolution scaling, use a CanvasScaler, you can configure it to scale UI depending on the screen size and using a reference resolution, the match mode determines how width and height are taken into account when calculating a scale.

alt text

If you are using LayoutElement then be sure to include a VerticalLayout or HorizontalLayout as well as a ContentSizeFitter into the ScrollView > View > Content, this will help manage the layout and sizes of the buttons.

alt text

There's plenty of information about putting buttons or other UIs into a ScrollView, I recommend checking the always-useful Unity Docs about the subject, here is a detailed explanation of the layout control: https://docs.unity3d.com/Manual/HOWTO-UIFitContentSize.html

There's also this cool Unity video-tutorial for example. It may appear to be a lot of reading/watching but in the end one should be more concerned about really understanding how things work than just hot-fixing.


screen-shot-2017-05-09-at-151552.png (45.1 kB)
screen-shot-2017-05-09-at-152515.png (72.0 kB)
Comment
Add comment · Show 2 · 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 Moubien · May 10, 2017 at 08:01 PM 0
Share

Thank your for your great reply I'm acctually depending on the video you put the link on and I'm having this issue when reducing the resolution

avatar image Moubien Moubien · May 10, 2017 at 08:03 PM 0
Share

I've set the parameter to false and the button now aligned perfectly but when I press the button they get smaller on every click which is very weird.

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

66 People are following this question.

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

Related Questions

Screen.width and Screen.currentResolution returning unwanted value 0 Answers

Android 2d game screen resolution 0 Answers

Ui scaling 1 Answer

How to animate UI rect transform which works for all resolutions 1 Answer

Neither CursorLockMode.Confined or SetResolution work 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