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 salkin99 · Apr 04, 2016 at 05:56 PM · camera viewport

make every player see the same picture with different aspect ratios?

I'm working on a 2D game right now, where it is very important that you have the same picture on your screen even with different screen ratios. Lately is stumbled upon the problem that Unity simply crops out everything that does not fit on the screen, so i tried to figure out a way to solve this problem. The free aspect of the camera is nearly 22 / 9, so the script simply compares the resolution of the script to this 22 / 9 ratio and makes the orthographic size of the camera bigger so everybody sees the same in width. The height varies though. Is that the only way or are there other and better ways out there to solve the problem?

     float cameraratio = 22 / 9;

     float screenwidth = Screen.width;

     float screenheight = Screen.height;

     float screenratio = screenwidth / screenheight;

     float multiplier = cameraratio / screenratio;

     camera.orthographicSize = camera.orthographicSize * multiplier;
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
0

Answer by elenzil · Apr 04, 2016 at 10:51 PM

look at the Canvas Scaler component on your UI Canvas.

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 salkin99 · Apr 05, 2016 at 10:58 AM 0
Share

I have no canvas' for now, but they wouldn't change with that script. With that it all stays the same (in width). Probably I don't get what you want to tell me.

avatar image
0

Answer by Peysbubby · Apr 05, 2016 at 02:22 PM

I believe what @elenzil is trying to say is: you said this is a 2D game, the picture you are talking about should be an "image" on the canvas of a 2D game. Once you have this you could take a look at the Canvas Scaler component of the canvas to possibly get the desired affect you are looking for.

Please correct me if I'm wrong, but I believe this is what he was getting at.

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 salkin99 · Apr 05, 2016 at 02:57 PM 0
Share

ups, i think I used the wrong words. Let's say I have a stage with 2 different players on the same screen. Both should be visible all the time, but on the same time the stage has borders. With a small aspect ratio of 5:4 the vision is very small. To make that big enough I would need to make the stage huge so users with for example 16:9 do not see these borders. I want to find a way where the width of the viewport is always the same, no matter if it is on a 5:4 ratio, or a 16:9 ratio.

avatar image elenzil salkin99 · Apr 05, 2016 at 04:37 PM 0
Share

well, if you want to avoid stretching, you have to allow the camera to crop some stuff out. the canvas scalar component i and Peysbubby are suggesting has a setting which lets you either keep the screen width or the screen height a constant across different aspect ratios. google "unity canvas scaler". there's much discussion.

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

How to set mini map camera to display entirety of the map 2 Answers

How to make the camera show only the part of the world which is in a specified rectangle? 0 Answers

Calculate camera position when angle is change but viewport bottom need to be fixed? 0 Answers

2D camera zoom out by the distance of player to an object, Zoom in when it gets further away 0 Answers

When playing a scene, Render LOD lines are visible? 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