Powered by
Follow Me
Top iOS tutorials
  • Blog
  • About
  • Contact

How to  check if the device is android or iOS in Unity 3D?

12/8/2017

 
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 ?

    Author

    I am Jitendra Gochhayat
    .I am a Sr. iOS Developer,Designer and blogger.I am passionate about writing blogs regarding Objective C & Swift concepts to help the iOS developers. 

    Archives

    December 2017
    November 2017
    May 2016
    April 2016
    March 2016
    December 2014
    October 2014
    September 2014
    August 2014

    RSS Feed

    Categories

    All
    Apple Updates
    Application's Background Transition Cycle In IOS
    Cocos2d-X IOS
    How To Explain IOS Application LifeCycle ?
    How To Explain UIViewController Life Cycle In IOS ?
    IOS Discussion
    IOS Interview Questions
    Objective C Concepts
    Swift
    Unity 3D
    Xcode

WELCOME TO iOSLINKER

SUSCRIBE TO NEWSLETTER

FOLLOW ME

Picture
    I am Jitendra Gochhayat,
    an iOS developer,blogger,
    from Odisha,India.
I write about Objective C tutorials,iOS interview Questions And Answers,swift tutorials and cocos2d-x sample codes to help the developers.

    Get instant notifications of new posts by Email

Subscribe to Newsletter
Picture
@2016 iOSLinker Powered by Weebly
Powered by
Powered by
✕