- Home /
"Am I running on iPhone? or WebPlayer? or Win32?" detecting it on runtime?
How can my app know the environment platform on runtime? For example, "Am I running on iPhone? or WebPlayer? or Win32?" Of course, I want to let my app know it on runtime, not compile time. (#if IPHONE something is not what I want to know.)
Please reply. Thanks in advance. Hyunjik Bae
Comment
Best Answer
Answer by Tseng · Dec 21, 2011 at 08:47 PM
http://unity3d.com/support/documentation/ScriptReference/Application.html
and
http://unity3d.com/support/documentation/ScriptReference/RuntimePlatform.html
switch(Application.platform) {
case RuntimePlatform.WindowsPlayer:
// Windows specific code
break;
case RuntimePlatform.WindowsWebPlayer:
// Windows webplayer code
break;
case RuntimePlatform.IPhonePlayer:
// iPhone
break;
case RuntimePlatform.WindowsPlayer:
break;
}
If you want to detect if its WebPlayer (and don't want to differentiate between MacOS/Windows), you can do
if(Application.isWebplayer) {
// is playing in webplayer
}
Your answer