How to Get Type of iOS Device?

Hello,

I am trying to resize screen view of my game by getting type of the iOS device. Actually, i only resize it for iPAD devices. But the code i give below doesn’t seem to work. When i run the project in iPAD simulator of xCODE, it doesn’t read the code and resize the game. What’s wrong with these codes or what should i use to get the type of the iOS devide?

I was using ‘iPhoneSettings.generation == iPhoneGeneration.iPad1Gen’ in Unity 4.x but it seems that it’s changed as this in unity 5; ‘UnityEngine.iOS.Device.generation == UnityEngine.iOS.DeviceGeneration.iPadMini3Gen’. I got no error when i type this but i think there is still something wrong.

What could be the problem?

any idea?

Maybe the simulator is returning a different device type - iOS.Device.generation is for checking specific devices, rather than entire device families, and I’m not sure what device the simulator will return (you could Debug.log the value to see).

A better way that is more future-proof is to get the screen’s aspect ratio - if the screen has an aspect ratio of 4:3 or 3:4, it’s an iPad or iPad Mini/Pro, if it’s 16:9 or 9:16 it’s an iPhone 5 or greater, if it’s 3:2 or 2:3 it’s an iPhone 4s or lower.

Dreamwriter thanks for your answer. I tested my previous projects in simulator and i was getting healthy results it was working well in the past but now i don’t know what is changed. Maybe it is because of the xCode version. You may be right about it. To get screen aspect ratio seems a good way. I will try that. Thanks for the idea. I will write the result in here. Thank you so much again!