- Home /
Question by
beugen · Jul 09, 2015 at 12:48 PM ·
androidandroid iphone
Android specific statement
Hi,
I want to write a small app for Android. The Awake() function looks like this:
void Awake(){
iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Landscape;
iPhoneKeyboard.autorotateToPortrait = false;
}
The problem is that the last statement :
iPhoneKeyboard.autorotateToPortrait = false;
is not recognized. How can I circumvent this situation or what specific statemnt for Android shoud I use ? Generally, where can I find a tutorial on Unity3d for Android because the tutorials on unity site are not very clear ?
Thnx
Comment
Answer by BiG · Jul 09, 2015 at 01:11 PM
You can detect the OS this way:
if (Application.platform == RuntimePlatform.IPhonePlayer)
iPhoneKeyboard.autorotateToPortrait = false;
else if(Application.platform == RuntimePlatform.Android)
//Other logic...
Or by using the preprocessor directives.
#if UNITY_IPHONE
... iPhone code here...
#endif
#if UNITY_ANDROID
... Android code here...
#endif