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 Jejkobb · Apr 24, 2019 at 08:44 PM · resolutionsettingsbuild settingslaptop

How do I keep everything inside of the screen on a laptop?

So everything works fine and dandy on my desktop PC with 1920x1080. But when I try on a MacBook which is 2560x1600 or 16:10 the game gets cut off on the left and right side. The images in the game are 16:9 which fill up the whole scene and are essiential to play the game. How do I make it so its always 16:9 no matter what resolution the player picks?

For example on a 16:10 screen I would not care if there were black bars on the top and bottom of the screen, as long as all of the image in game is visible. Is there a setting in the player/build settings that can help me achieve this? Even if I allow only 16:9 and start the build the only available resolution on the mac is 1280x800, which is not even 16:9.

I hope you understand my problem. Thank you for your help.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by DiegoSLTS · Apr 27, 2019 at 01:45 PM

Unity sets the aspect ratio of the camera to match your screen aspect ratio, but you can change it on runtime using: https://docs.unity3d.com/ScriptReference/Camera-aspect.html

If you set the aspect ratio to a fixed value, you'll see the same stuff in any screen you play, but the image will be stretched to fit the whole screen. If you want everything with the correct proportions you should change the "viewport" (as shown in the inspector) too using: https://docs.unity3d.com/ScriptReference/Camera-rect.html

This will result in the sides of the screen not being used by the camera. If you do all this with a black screen you'll end up with black bars at the sides like you wanted.

Another solution could be to set the aspect ratio, then render the main camera to a RenderTexture, and then using that render texture in a UI RawImage centered, with a AspectRatio constraint. This one can be setup easier in the editor, but it has some unnecessary overhead.

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 DiegoSLTS · Apr 27, 2019 at 01:55 PM 1
Share

Also, there's another, uglier solution. You can just render the game with the default configuration and make an Overlay Canvas with some black bars at the sides, and then set their positions at runtime based on the screen aspect ratio to cover what you don't want to show to the player. Again, this has some overhead and it's an ugly solution, but would have the same result.

avatar image Jejkobb · Apr 27, 2019 at 01:55 PM 0
Share

Thanks so much, I'll try this.

avatar image
0

Answer by Eyes-Wide-Shut · Apr 25, 2019 at 02:16 AM

You should never make your game with the intention of a single aspect ratio or resolution, rather you should adjust your game to the player's system. You can change the aspect ratio of the camera with the Viewport Rectangle property. https://docs.unity3d.com/ScriptReference/Camera-rect.html

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 DiegoSLTS · Apr 27, 2019 at 01:51 PM 1
Share

The viewport property only affects what part of the screen the camera uses, it doesn't affect the aspect ratio of the actual camera.

Also, "you should never" is not a good advice. There are games that might need a single aspect ratio for their mechanics and there are ways to make it work, so wanting a fixed aspect ratio is as valid as supporting any aspect ratio.

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

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

What are the most common screen resolutions to have in my options menu 1 Answer

How to set screen resolution 1 Answer

Max screen resolution and delete the ones that are higher? 1 Answer

How I can sign my apk with an google play's upload certificate in unity? 5 Answers

Ingame Quality Settings not recognized 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