Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by shapirog · Sep 27, 2018 at 01:36 AM · iosiphone

Using UnityEngine.iOS.DeviceGeneration to detect iPhone XS

Hello,

I've been using "if (UnityEngine.iOS.Device.generation == UnityEngine.iOS.DeviceGeneration.iPhoneX)" to detect if the user is on an iPhone X, and move several UI elements away from the notch. It's been working fine, but a beta tester who just got the iPhone XS said that it doesn't work on his phone. I'm guessing it's because I should be using DeviceGeneration.iPhoneXS or something, but according to the documentation there's only an entry for iPhone X. Is there a simple way to fix this that I'm not aware of? I tried searching, but couldn't find anything about it. Thank you!

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 Hellium · Oct 01, 2018 at 07:02 AM 0
Share

Have you tried DeviceGeneration.iPhone$$anonymous$$ https://docs.unity3d.com/ScriptReference/iOS.DeviceGeneration-iPhone$$anonymous$$.html ?

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Rick66 · Sep 30, 2018 at 09:21 PM

 Here is the strategy that I've been using...
 
 1. Check that the device is an iPhone:
 
      if (System.deviceModel.IndexOf("iPhone")) > -1
     
 2. If so, determine the ratio of screen width to height (convert ints to floats):
 
      screenRatio = (1.0*Screen.width)/(1.0*Screen.height)
      
 3. Then if:
 
      1.4 < screenRatio < 1.6   // 3:2 iPhones - models 4 and earlier
      1.7 < screenRatio < 1.8   // 16:9 iPhones - models 5, SE, up to 8+
      2.1 < screenRatio < 2.2   // 19.5:9 iPhones - models X, Xs,  Xr, Xsmax
 


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 shapirog · Oct 02, 2018 at 05:35 AM 0
Share

Ended up going with this - thanks

avatar image rcamduell · Oct 30, 2018 at 10:10 AM 0
Share

If your game is in portrait mode, divide height by width ins$$anonymous$$d, to use the same values.

avatar image
0

Answer by jonarnes · Oct 01, 2018 at 06:43 PM

If you have a web app or a website you can detect any iPhone model using wurfl.js You simply include this javascript on you page:

 <script type="text/javascript" src="//wurfl.io/wurfl.js"></script>

and then a JavaScript object is available in the DOM:

 WURFL= {
     "is_mobile": true,
     "complete_device_name": Apple iPhone Xs,
     "form_factor": smartphone
 }

Comment
Add comment · 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

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

195 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 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 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 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 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 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 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 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

linker command failed with exit code 1(use -v to see invocation) 2 Answers

Texture tilling problem on iOS 2 Answers

iOS build not rendering properly 1 Answer

Failed to connect iPhone XR to unity editor 1 Answer

Local Notification Badge Not Working On iPhoneX (iOS 11.4) 0 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