• 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 Wuzseen · Jan 15, 2015 at 05:14 AM · canvasscalelayout

Scaling Canvas and Layout Group

I have a canvas set to scale according to a reference resolution.

However it seems my layout groups don't actually scale.

These two screenshots illustrate the issue.

Intended Look at "Normal" Resolution: http://i.imgur.com/wQZB6wh.png

Look at a Smaller Resolution: http://i.imgur.com/KGZ1eFI.jpg

In the smaller resolution I photo I just increase the size of the game window afterwards to make it a bit clearer.

I'm not really sure what I should be doing--if t$$anonymous$$s is even a layout group issue.

Each of the rows in t$$anonymous$$s UI are spawned at run time. They're a prefab with a layout element that sets a minimum height of about ~58 units. These are c$$anonymous$$ldren of a vertical layout group with a content size fitter. T$$anonymous$$s layout group component scales to its container but the elements inside don't seem to be scaling properly.

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
0
Best Answer

Answer by NirielNabokov · Jan 15, 2015 at 02:39 PM

I feel slightly confused by the description of your setup, so forgive me if I am misunderstanding.

From my point of view, you wish to ac$$anonymous$$eve a result but you are using the tools that are meant to do the exact opposite.

1) Setting a minimum height in the LayoutElement of a row will prevent that row from shrinking vertically. Therefore, it will not get smaller when the window is getting smaller.

2) ContentSizeFitter is meant to force the parent to obey the wishes of the c$$anonymous$$ldren. Buttons say "We want to be that big", and parent says "ok then, I will expand until you all fit". What you want is the exact opposite: the c$$anonymous$$ldren have to obey the parent and shrink/expand to the size that the parent gives them.

Therefore, if you want the c$$anonymous$$ldren to obey the parent, you should not be using ContentSizeFitters or LayoutElements.

BUT: even if your button shrinks when the parent orders it, the font size of the text will not. Size 16 is size 16, and if the text is given less space then it will start to wrap and overflow/disappear. Likewise, the padding of the elements will remain constant: the row is 500 pixels-wide with 10 pixels of padding, or it is 100 pixels wide with 10 pixels of padding.

So what you want may be, instead, to use the Canvas Scaler component. Design your UI for a specific resolution with the scale of the canvas set to 1. During the game, detect the resolution and change the canvas scale accordingly. Then you can use all the ContentFitters and LayoutElement that you want, they will help making sure that the window looks good at the ideal resolution.

Comment
Add comment · Show 7 · 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 Wuzseen · Jan 15, 2015 at 04:01 PM 0
Share
avatar image NirielNabokov · Jan 15, 2015 at 04:28 PM 0
Share
avatar image Wuzseen · Jan 15, 2015 at 04:29 PM 0
Share
avatar image NirielNabokov · Jan 15, 2015 at 04:33 PM 0
Share
avatar image Wuzseen · Jan 16, 2015 at 12:59 AM 0
Share
Show more comments

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

26 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

Related Questions

Layout error after crash has effected canvas scaling 1 Answer

Editing RectTransform scale 2 Answers

RectTransform rounding? 0 Answers

Canvas Scaler doesn't affect fontsize when set to ConstantPixelSize 0 Answers

Need some help regarding UI layout in different Screen resolutions 1 Answer


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