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 markzareal · Mar 28, 2015 at 04:59 AM · cameraxcoderesolutions

Fitting camera in different resolutions.

I built my 2d game to xcode and ran it on the ios simulator for 3.5 inch (iphone 4s). The camera is cut off. How do I make it so that the camera would not cut off in smaller resolutions? It is ok if the contents seem squished or stretched.

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 maccabbe · Mar 28, 2015 at 05:08 AM

Use Camera.aspect, for instance if we wanted a 4:3 ratio use

 Camera.main.aspect=4f/3f;


http://docs.unity3d.com/ScriptReference/Camera-aspect.html

Comment
Add comment · Show 5 · 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 markzareal · Mar 28, 2015 at 05:16 AM 0
Share

How can the script recognise that the device used is an iphone 4s? Is there an if statement for that? I don't want the aspect to change because the camera would be smaller and would cut off parts of the screen. Is there a way to squish in the content in the camera?

avatar image sumeeton · Mar 28, 2015 at 05:24 AM 0
Share

Yes, you can use the preprocessor directives that are platform dependent:

 #if UNITY_IPHONE
    // your code here
 #endif

Or you can use this:

 if(Application.platform == RuntimePlatform.IPhonePlayer)
 {
      // your code here
 }

To know the aspect ratio, use Screen.width & Screen.height

avatar image markzareal · Mar 28, 2015 at 05:29 AM 0
Share

Doesn't changing the aspect causes the screen to get cut off though? @sumeeton

avatar image sumeeton · Mar 28, 2015 at 05:39 AM 0
Share

Okay here's the thing. While designing the game you need to setup scenes such a way that it supports different aspect ratios you intend to. You can check this in the game view. Camera doesn't cut off the scene for a display. It'll display the actual content that can be displayed for the given aspect ratio of the screen. Now that you have already built the scenes, we can make changes to the camera to avoid reconstructing the scenes. Select the camera and adjust the Field of View property and test it out in the Game View with the desired aspect ratio.

avatar image sumeeton · Mar 28, 2015 at 05:55 AM 0
Share

Changing aspect will definitely affect the contents rendered. It is up to you to how to use the aspect property.

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

20 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

Related Questions

How to make camera position relative to a specific target. 1 Answer

iOS 10.0.2 shows blank screen? 0 Answers

Signing C++ Plugins For the Mac App Store 0 Answers

Signing C++ Plugins For the Mac App Store 1 Answer

Problems with camera animations in Unity 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