- Home /
Detecting iPad with C#
Hello,
I have a mobile game with a GUI HUD. I use some calculations using screen.width and screen.height. This works fine on Android, but because iOS devices set the screen.height differently my HUD is all messed up. I want to fix this using a simple if statement:
if (Application.platform == RuntimePlatform.Android)
and
if (Application.platform == RuntimePlatform.IPhonePlayer)
But RuntimePlatform only has a iPhonePlayer. Because I am working with an iPad this doesn't seem to work.
Do any of you guys (and girls) know how I can detect iOS of all kinds?
Thanks,
Nils
I'd like to re$$anonymous$$d you to ACCEPT THE ANSWERS if it helped you. Seeing your history you did not do it :)
Answer by Xitech_ · Oct 30, 2014 at 09:52 AM
if((iPhone.generation.ToString()).IndexOf("iPad") > -1){
//bla bla
}
This question has been answered here:
http://answers.unity3d.com/questions/552549/check-is-iphone-or-ipad.html
if(SystemInfo.device$$anonymous$$odel.Contains("iPad").ToString().IndexOf("iPad") > -1){ //bla bla }
Please be cautious using this method and don't rely on it for anything critical. When new generation of devices are out, old version of unity will not detect them correctly.
Prefer checking screen size ins$$anonymous$$d.
Answer by lateKnight9060 · Apr 19, 2016 at 12:15 PM
Actually its: if(SystemInfo.deviceModel.Contains("iPad")) { //Do Stuff here }
Answer by SnailGirl · Mar 01, 2018 at 10:11 PM
does anyone know if there's a way of debugging these functions in unity? as in simulating opening in an ipad/iphone?
Answer by Silverlode · Mar 10, 2019 at 10:14 PM
UnityEngine.iOS.Device.generation.ToString().Contains("iPad");
Would this also be acceptable and reasonably`enter code here` future-proof?
Your answer
Follow this Question
Related Questions
iPhone Controller Asset 0 Answers
Screen.sleepTimeout works when application runs in background on iOS (iPad) 0 Answers
Specifying a high quality background image for iPad 1 Answer
Keyboard triggered animation not showing on IOS device 0 Answers
App crash when using siri dictation to replace text on iOS 0 Answers