unity3d Compiler Definitions


Example

Compiler definitions run platform specific code. Using them you can make small differences between various platforms.

  • Trigger Game Center achievements on apple devices and google play achievements on Android devices.
  • Change the icons in menus (windows logo in windows, Linux penguin in Linux).
  • Possibly have platform specific mechanics depending on the platform.
  • And much more...
void Update(){ 

#if UNITY_IPHONE
    //code here is only called when running on iPhone
#endif

#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
    //code here is only ran in a unity game running on windows outside of the editor
#endif

//other code that will be ran regardless of platform

}

A complete list of Unity compiler definitions can be found here