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 TheCount · Feb 09, 2014 at 07:38 PM · javascriptresolutionscreen

Screen Resolution Scaling No Solution?

I have searched and searched, but I can't seem to find any way to fix this.

I am creating an android app, and I would like it to just scale to the screen size so the ratio is the same no matter what the screen size is.

With my app it is perfectly ok if things appear stretched.

I just want it to look the exact same as if it were in a 16 by 10 window at 1280 by 800.

HOW CAN I FIX THIS

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
1

Answer by robertbu · Feb 09, 2014 at 08:59 PM

You can do what you are asking here by setting up a custom projection matrix for the camera. I've never researched camera projection matrices, so I don't know all the implications of making the change. Example code:

 #pragma strict
 
 private var baseAspect : float = 1280.0 / 800.0;
 
 function Start() {
     var currAspect : float = 1.0 * Screen.width / Screen.height;
     Debug.Log(Camera.main.projectionMatrix);
     Debug.Log(baseAspect + ", " + currAspect + ", " + baseAspect / currAspect);
     Camera.main.projectionMatrix = Matrix4x4.Scale(Vector3(currAspect / baseAspect, 1.0, 1.0)) * Camera.main.projectionMatrix;
 }
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 TheCount · Feb 10, 2014 at 12:30 AM 0
Share

That doesn't quite work. $$anonymous$$y camera is orthographic and set to a size of 5. I want everything that that camera sees in it's 5, to be showed on the screen and scaled to the screen.

avatar image robertbu · Feb 10, 2014 at 01:18 AM 0
Share

I had the division backwards. I edited the code above I tested it. It now works as you describe.

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

18 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

Related Questions

Multiple Cars not working 1 Answer

Pick sensible resolution for FullScreen Mac App 2 Answers

Multi touch (help have issues) 1 Answer

Screen.SetResolution doesn't work when the game starts windowed? 0 Answers

How do I deselect an object when another is selected? 2 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