Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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
3
Question by ez06 · Jul 31, 2015 at 01:27 PM · screen resolution

How can I check if it's a tablet? (both iOS and Android)

I used to check if Screen.height was greater than 1024, but this doesnt work anymore since recent iPhones have 1136 and higher (and Android phones too)

How can I now check that the device is a tablet (or NOT a mobile phone)?

Comment
Add comment · Show 2
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 tanoshimi · Jul 31, 2015 at 01:44 PM 0
Share

You simply want to know whether the device is also capable of making/receiving phone calls? Why?

avatar image ez06 · Jul 31, 2015 at 01:45 PM 0
Share

I want to know if the screen size is large. To adapt my game controls

3 Replies

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

Answer by NeverHopeless · Jul 31, 2015 at 01:55 PM

You may consume this function:

 //calculate physical inches with pythagoras theorem
 public static float DeviceDiagonalSizeInInches ()
 {
     float screenWidth = Screen.width / Screen.dpi;
     float screenHeight = Screen.height / Screen.dpi;
     float diagonalInches = Mathf.Sqrt (Mathf.Pow (screenWidth, 2) + Mathf.Pow (screenHeight, 2));
 
     Debug.Log ("Getting device inches: " + diagonalInches);
 
     return diagonalInches;
 }

and use it like:

 if(Application.platform == RuntimePlatform.Android && DeviceDiagonalSizeInInches() > 6.5f)
 {
 
     // Tablets
 }


Hope it helps!

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 ez06 · Jul 31, 2015 at 01:59 PM 0
Share

Thanks for that!!

avatar image Cress7 · Jul 09, 2016 at 10:46 PM 0
Share

Sometimes it doesn't work.

avatar image
3

Answer by austinborden · Dec 27, 2019 at 03:22 PM

Through some beta testing on Android I've found there's at least one phone out there that gets reported as a tablet with this code, the OnePlus GM1913. Its screen is 1080x2340 at 380 dpi. To restrict this a bit more, I added an aspect ratio test. I'm not aware of any tablet that has an aspect ratio greater than 2:1. Using @NeverHopeless answer, add the aspect ratio check like this:

 var aspectRatio = Mathf.Max(Screen.width, Screen.height) / Mathf.Min(Screen.width, Screen.height)
 var isTablet = (DeviceDiagonalSizeInInches() > 6.5f && aspectRatio < 2f);
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
avatar image
-2

Answer by kemar · Jul 31, 2015 at 01:30 PM

Hi,

You can use this:

 function Start () {
          if (Application.platform == RuntimePlatform.Android)
              print ("Android");
          else if(Application.platform == RuntimePlatform.IPhonePlayer)
              print("Iphone");
      }

Take a look here link text And here link text

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 ez06 · Jul 31, 2015 at 01:31 PM 0
Share

Hi thanks for the response. But I'm asking how to check if it's a tablet, not it's platform.

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

26 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

Related Questions

size of window 0 Answers

Screen Resolution -1 Answers

How to disable object scaling when screen height is changing 0 Answers

Screen.currentResolution values don't change after SetResolution in Mac builds 1 Answer

I have problems with the Camera.ortographic to adapt the view to screens with different resolutions. 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