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 dep2k · Feb 11, 2014 at 08:48 PM · screensize

Random screen height and width when platform is set to IOS.

I have my game view set for iPhone5 Tall(9:16) size. In the script when I am checking the width and height of screen, I get unknown width and height. Here's the code that I've used:

 function Start () 
 {
 
     Debug.Log( "ScreenWidth:" + Screen.width + "ScreenHeight:" + Screen.height);
     
 }

In the Editor, I get this for iPhone 5(9:16) - ScreenWidth:203ScreenHeight:361 and for iPhone 4 Tall(640*960) - ScreenWidth:240ScreenHeight:361

Shouldn't the size for iPhone5 be:(640*1136) and for iPhone4: (640*960)

I am new to Unity IOS development. If anyone can help me understand the concept, I would be very thankful.

Comment
Add comment · Show 6
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 Graham-Dunnett ♦♦ · Feb 11, 2014 at 11:10 PM 2
Share

I think when running in the editor you get the actual width and height of the game view window, scaled to fit the aspect ratio you have chosen. So, in iPhone5(9:16) mode, your window is 361 pixels high, so, to give you a 9:16 aspect ratio you need 203 pixel width. If your game window is 1136 pixels tall, then you'll get a width of 640, which I think is what you want.

avatar image AdamScura · Feb 11, 2014 at 11:36 PM 0
Share

To follow up on the comment by Graham...

Set your target platform to iOS. Then you can pick the correct iOS screen size in the "Aspect Dropdown" of the game view.

https://docs.unity3d.com/Documentation/$$anonymous$$anual/PublishingBuilds.html

https://docs.unity3d.com/Documentation/$$anonymous$$anual/GameView40.html

avatar image AdamScura · Feb 11, 2014 at 11:40 PM 0
Share

By the way, Graham. How do I @ reference you? Your name has a space in it and if I type @Graham Dunnett it points to some other guy.

avatar image dep2k · Aug 23, 2014 at 06:52 AM 0
Share

Thank you guys for the answers. It solved my problem.

avatar image supernat · Aug 23, 2014 at 07:25 AM 0
Share

This stumped me a bit too, but it does make some sense, because the viewport size is based on the PC's game window when you're viewing it. However, it would be nice to have a "lock to specific resolution" feature that would make the game window lock to the proper resolution. I just manually enforced this by resizing the game window to the proper height as a floating window, and then you can test your code properly.

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

22 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

Related Questions

Windows publishing wrong screensize?! 2 Answers

Set Game View Resolution 1 Answer

Box Collider 2D Not Scaling Correctly On Different Devices 1 Answer

Auto Scale camera depending on Screen Size - How?? 3 Answers

GUI Label Text Sizing problem 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