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
0
Question by billkell · Jan 23, 2018 at 03:59 AM · canvasscalingpanelscreen sizeoverlay

Scaling panel by different screen sizes

Let's say I want a UI panel on a canvas to always take up the left 1/3 of my screen. I want the panel height to always match the screen height, and the panel width to always match 1/3 of the screen width.

If I wanted to have the panel take up the middle 1/3 of the screen, I can do this:

  1. Make canvas scale by height, such that the canvas always has the height of the screen.

  2. Attach panel as child to canvas

  3. Set panel x scale to 0.33

Is there a way to anchor the panel to the left side of the screen using Rect Transform? I can't seem to find a combination of anchor/pivot/position that behaves as I expect it to.

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

Answer by Neamtzu · Jan 23, 2018 at 09:15 AM

Scaling the UI elements without properly settings the anchors can produce unexpected behaviour. The solution will be to keep the scale to 1, set the size of the panel for your default resolution and then just set the anchors in each corner.

Comment
Add comment · Show 6 · 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 billkell · Jan 23, 2018 at 12:56 PM 0
Share

But then the width of the panel varies by screen resolution, right? I’m hoping to have the panel always be 1/3 of the screen, which I seem to be only have to set via scale, but then it will slide to take up more or less of the screen if I set anchors and change the resolution

avatar image Neamtzu billkell · Jan 23, 2018 at 01:37 PM 0
Share

Basically the anchors are defined in fractions (or percentages) of the parent rectangle width and height. If the object you want to be 1/3 of the screen is child of an object that is scaled with the screen size, when the resolution changes your object should update as well.

avatar image billkell Neamtzu · Jan 23, 2018 at 01:51 PM 0
Share

Ah, so that’s where I’m running into my problem - I can only scale my parent in 3 ways that I know of: by height, by width, or some ratio of the two. Can you scale a parent to be percentages of each screen size?

avatar image Neamtzu billkell · Jan 23, 2018 at 01:55 PM 1
Share

See this example $$anonymous$$y canvas is set to scale with the screen resolution, base resolution is 1080 x 1920. I made that image 1/3 of the screen resolution, which means 360 x 640. As you can see, I can freely resize the game window and the blue space in each size is proportional. This works if you place the image anywhere on the screen, as long the anchors are positioned correctly.

avatar image Harinezumi Neamtzu · Jan 23, 2018 at 04:19 PM 1
Share

This is a really good example. I think this comment should be converted into an answer.

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.

Follow this Question

Answers Answers and Comments

80 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 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

Box Collider 2D Not Scaling Correctly On Different Devices 1 Answer

Canvas Scaling! 0 Answers

Fit application to any device resolution 1 Answer

Create pop menu Sims's style when click on 3d Character 1 Answer

Moving a UI object from one Canvas to another doesn't apply scaling 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