Question by
punkrockchicken · Nov 14, 2017 at 09:16 PM ·
iosiphoneipaddevice
How to detect iPhone X or iPad using iOS.DeviceGeneration?
i.e if it is an ipad(any) or iPhoneX then i want to open a different scene. How do I do it?
if(...detect iPad(any) or iPhoneX ...) {
SceneManager.LoadScene("SpecificScene");
}
Thank you
Comment
Answer by -chris · Jan 13, 2018 at 01:33 AM
You can check against UnityEngine.iOS.Device.generation.
Note that you'll need Unity 2017.2 or higher to detect iPhone X.
Unity 5.6.5f1 also seems to support the iPhoneX enum, even though it's not listed in the 5.6 docs.
bool deviceIsIphoneX = UnityEngine.iOS.Device.generation == UnityEngine.iOS.DeviceGeneration.iPhoneX;
if (deviceIsIphoneX) {
// Do something for iPhone X
}
To check against iPad, you could probably go:
bool deviceIsIpad = UnityEngine.iOS.Device.generation.ToString().Contains("iPad");
if (deviceIsIpad) {
// Do something for iPad
}