• 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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

Does Resolution of images used in game affect performance on Low End Devices? 0 Answers

Is it possible to make unity's camera render in chunky pixels? 2 Answers

How can I make my mobile game compatible for all screen sizes? 0 Answers

Fill screen with Unity WebGL while maintaining display ratio 0 Answers

Moving game object have different speeds in different screen resolutions and it's jittering 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges