Unity3D/Tips

[펌] How to detect iPhone X or iPad using iOS.DeviceGeneration?

blueasa 2018. 3. 9. 20:45

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. 

  1. bool deviceIsIphoneX = UnityEngine.iOS.Device.generation == UnityEngine.iOS.DeviceGeneration.iPhoneX;
  2. if (deviceIsIphoneX) {
  3. // Do something for iPhone X
  4. }


To check against iPad, you could probably go:

  1. bool deviceIsIpad = UnityEngine.iOS.Device.generation.ToString().Contains("iPad");
  2. if (deviceIsIpad) {
  3. // Do something for iPad
  4. }


[출처] https://answers.unity.com/questions/1432365/how-to-detect-iphone-x-or-ipad-using-iosdevicegene.html

반응형