- Home /
iOS namespace not found in unity engine
I need to check the device type in my code. I use a line like:
return UnityEngine.iOS.Device.generation.ToString().IndexOf("iPad") > -1;
This compiles in the editor but on building an executable, I get an error - The type or namespace iOS does not exist in the namespace UnityEngine. I assume this is because I am building something for a windows platform, so iOS is not recognized. The app needs to be able to function on multiple platforms and it needs to know what platform it is on, so how do I get this to compile on windows?
Looking into preprocessor directives now. I'll post the solution if I find it.
Answer by rodeowild · Aug 07, 2017 at 05:29 PM
Found a solution. Easiest way to go is with the following code:
#if UNITY_IOS
return UnityEngine.iOS.Device.generation.ToString().IndexOf("iPad") > -1;
#else
return false;
#endif
Your answer
Follow this Question
Related Questions
Show device info such as resolution, OS, GPU, etc... 1 Answer
Unable to export an iOS build on Windows - Using version 5.3.4f1 1 Answer
Not a valid asset name, unallowed characters in file name, Refresh Case Sensitivity Failure. 4 Answers
Dim Screen but Don't Lock 0 Answers
[iOS] Asking for location services does not present alert request to user 4 Answers