There are some cases where RuntimePlatform is needed to be checked at runtime.We have several ways to check at compilation time and run time whether a device is iPhone or Android.
|
The best way is to use the preprocessor.
Solution 1: #if UNITY_IOS iPhone related codes #endif #if UNITY_ANDROID Android code here #endif |
Solution 2:
if (Application.platform == RuntimePlatform.Android
print ("Android related functions");
else if(Application.platform == RuntimePlatform.IPhonePlayer)
print("iPhone related functions only");
Read:
What are the differences between Cocoa and Cocoa Touch?
some key concepts for an iPhone developer to learn as a fresher
What are best practices that you use when developing projects in Objective-C ?
if (Application.platform == RuntimePlatform.Android
print ("Android related functions");
else if(Application.platform == RuntimePlatform.IPhonePlayer)
print("iPhone related functions only");
Read:
What are the differences between Cocoa and Cocoa Touch?
some key concepts for an iPhone developer to learn as a fresher
What are best practices that you use when developing projects in Objective-C ?