Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 maddFrogg · Apr 08, 2014 at 08:04 AM · camerascreenscreen.width

Keeping screen width and scaling screen height for different screen resolutions

Hi guys,

I need my game to have a constant screen width for every mobile device in the market. For this I need to scale the screen height in order to keep the same screen width, even though the screen ratio varies.

Here you have an example:

alt text

alt text

You see the width is the same for both resolutions and only the screen height varies.

Any idea of how I can do this?

Thanks in advance!

EDIT:

Found this: http://gamedesigntheory.blogspot.ie/2010/09/controlling-aspect-ratio-in-unity.html

Is there a way to edit it to scale height instead of adding black frames? (keeping the width)

Up!

forest-gameplay (1).png (271.2 kB)
forest-gameplay.png (246.5 kB)
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 elhispano · Apr 08, 2014 at 09:10 AM

You need to change your camera orotographics size following the next formula:

 ortographicSize = constantWidth / aspectratio * 2f;
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 maddFrogg · Apr 08, 2014 at 09:21 AM 0
Share

Sorry, maybe the screenshots weren't much accurate. $$anonymous$$y camera is 3D.

avatar image Klarax · Apr 08, 2014 at 09:53 AM 0
Share

try using Screen.SetResolution as seen in the documentation

     function Start()
     {
         var resolutions : Resolution[] = Screen.resolutions;
         // Print the resolutions
         for (var res in resolutions) {
             print(res.width + "x" + res.height);
         }
         // Switch to the lowest supported fullscreen resolution
         Screen.SetResolution (resolutions[0].width, resolutions[0].height, true);
     };
avatar image
0

Answer by Patel-Sagar · Apr 08, 2014 at 10:11 AM

try this:

     var verticalFOV : float =60;
     var forcedAspectRatio: float = 0.75;
     var manualNearClipPlane : float = 0.01;
     var manualFarClipPlane : float = 1000;
      
     function Update(){
         camera.projectionMatrix = Matrix4x4.Perspective(verticalFOV, forcedAspectRatio, manualNearClipPlane, manualFarClipPlane);
     }
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 maddFrogg · Apr 25, 2014 at 08:48 AM 0
Share

Doesn't work for me, sorry :(

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

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

Detect touch in screen at different resolutions 2 Answers

how to have an object positioned relative to the screen(like a button) 1 Answer

UI render doesn't sync with Camera movement 2 Answers

scaling (Resizing) orthographic camera in 2D mode 3 Answers

Why doesn't my players camera work and why does it spaz out randomly 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