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 N30N · Mar 30, 2015 at 10:48 PM · iosmobileiphoneaspect-ratio

iphone screen size

anyone know how to make a game's screen size fit right for iphone 5 and 6? i wan't it so that when i'm working on unity, it's in the same size as iphone and can detect if it's on iphone's screen.

now i'm using the free aspect ratio. I set the dimensions to 1136 x 640 and i'm working on windows

Comment
Add comment · Show 1
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 moghes · Mar 31, 2015 at 06:54 AM 0
Share

What type of game? is it 2D or 3D ? are you using the new UI or a third party?

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by eelstork · Mar 31, 2015 at 02:44 AM

As to iPhone screen sizes it's all here.

Add a custom screen size to the editor, click the "free aspect" widget and use the + sign at the bottom of the drop down menu.

As to detecting the size of the target device, have you tried? Last time I built a Unity project on an iOS device I seem to recall having done nothing special to get it to work at target device resolution.

Bear in mind that you will need an OS-X computer (aka, a Mac) to create an iPhone/iPad build.

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 N30N · Mar 31, 2015 at 04:38 AM 0
Share

is there a way i can get the build to run at a different aspect ratio when building to pc or web but still detect iphone screen size when building to iphone?

avatar image eelstork · Mar 31, 2015 at 09:02 AM 0
Share

Different iPhone screens have different aspect ratios. So, as to picking the correct aspect ratio for rendering I believe that Unity does this automatically for your main camera. You can easily detect the screen size at runtime, and enforce whatever aspect ratio you like accordingly (even letterboxing etc...). For example see here. (not the only script lying around) As to handling things differently on a platform specific basis you are looking for platform dependent compilation. As another suggested, knowing whether you are creating a 2D or 3D game (or dealing with these related to the UI or scene...) will help us understand what you're getting at.

Please try to improve your question. $$anonymous$$aybe your question should be "How to manage aspect ratio across devices?" ins$$anonymous$$d of iPhone screen size, which isn't really a question, and will be overlooked as potentially not related to Unity 3D. It is poor form to ask additional questions in comments. If the added question doesn't stand in its own right, consider updating the original question.

avatar image
0

Answer by alok-kr-029 · Mar 31, 2015 at 06:27 AM

I set the screen size to one aspect ratio and update as so it work perfect for me for any screeen size

 void Start ()
     {
 
         if( this.GetComponent<Camera>().aspect > 0.7f  && this.GetComponent<Camera>().aspect < .8f)
         {
             //print ( this.GetComponent<Camera>().aspect );
             GetComponent<Camera>().orthographicSize = 6.46f;
         }
         else if(this.GetComponent<Camera>().aspect > 0.52f  && this.GetComponent<Camera>().aspect < .58f)
         {
             //print ( this.GetComponent<Camera>().aspect );
             GetComponent<Camera>().orthographicSize = 8.38f;
         }
 
         else if(this.GetComponent<Camera>().aspect > 0.6f  && this.GetComponent<Camera>().aspect < .67f)
         {
             //print ( this.GetComponent<Camera>().aspect );
             GetComponent<Camera>().orthographicSize = 7.18f;
         }
 
         else if(this.GetComponent<Camera>().aspect > 0.55f  && this.GetComponent<Camera>().aspect < .59f)
         {
             //print ( this.GetComponent<Camera>().aspect );
             GetComponent<Camera>().orthographicSize = 8.21f;
         }
     }
     
     

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 RyanFaeScotland · Mar 31, 2015 at 09:25 AM 0
Share

You may already know this but ins$$anonymous$$d of making up to 8 calls to

 this.GetComponent()<Camera>.aspect

you could set a couple of variables at the start for more efficient and easier to read code.

 var cameraComponent = this.GetComponent<Camera>();
 var cameraAspect = cameraComponent.aspect;
 
 if (cameraAspect > 0.7f && cameraAspect < 0.8f)
 {
     cameraComponent.orthographicSize = 6.46f;
 }
 ...



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

21 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

Related Questions

Unity 3.5 allows terrains on iPad2 and newer iOS devices, what's the max terrain size? 0 Answers

Splash screen orientation - iOS 2 Answers

How to have my mobile device screen lighting on all the time 2 Answers

Using dual touchpad prefab 0 Answers

What is causing a single hiccup at start of IOS game? 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